From 11c4dbe993aec1c81310e0c6d72c8bcddbec7496 Mon Sep 17 00:00:00 2001 From: Carlo von lynX Date: Sun, 8 May 2016 10:06:50 +0000 Subject: [PATCH] cmdline usability for gnunet-social --- src/social/gnunet-social.c | 147 +++++++++++++++++++------------------ 1 file changed, 74 insertions(+), 73 deletions(-) diff --git a/src/social/gnunet-social.c b/src/social/gnunet-social.c index 4eb427f57..a3ad95270 100644 --- a/src/social/gnunet-social.c +++ b/src/social/gnunet-social.c @@ -106,9 +106,9 @@ static int opt_refuse; /** --method */ static char *opt_method; -/** --data */ -// FIXME: could also come from STDIN -static char *opt_data; +/** --body */ +// FIXME: should come from STDIN +static char *opt_body; /** --name */ static char *opt_name; @@ -255,6 +255,7 @@ static void guest_leave () { struct GNUNET_PSYC_Environment *env = GNUNET_PSYC_env_create (); + // method in the middle of vars? FIXME GNUNET_PSYC_env_add (env, GNUNET_PSYC_OP_SET, "_notice_place_leave", DATA2ARG ("Leaving.")); GNUNET_SOCIAL_guest_leave (gst, env, &guest_left, NULL); @@ -735,7 +736,7 @@ host_reconnected (void *cls, int result, host_leave (); } else if (op_host_announce) { - host_announce (opt_method, opt_data, strlen (opt_data)); + host_announce (opt_method, opt_body, strlen (opt_body)); } else { place_reconnected (); @@ -755,7 +756,7 @@ guest_reconnected (void *cls, int result, guest_leave (); } else if (op_guest_talk) { - guest_talk (opt_method, opt_data, strlen (opt_data)); + guest_talk (opt_method, opt_body, strlen (opt_body)); } else { place_reconnected (); @@ -919,8 +920,8 @@ run (void *cls, char *const *args, const char *cfgfile, if (!opt_method) opt_method = "message"; - if (!opt_data) - opt_data = ""; + if (!opt_body) + opt_body = ""; if (!opt_name) opt_name = ""; @@ -990,78 +991,70 @@ main (int argc, char *const *argv) /* operations */ - { 'u', "status", NULL, - gettext_noop ("list of egos and subscribed places"), - GNUNET_NO, &GNUNET_GETOPT_set_one, &op_status }, - - { 'E', "host-enter", NULL, + { 'C', "host-enter", NULL, gettext_noop ("create a place"), GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_enter }, - { 'H', "host-reconnect", NULL, - gettext_noop ("reconnect to a previously created place"), - GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_reconnect }, - { 'D', "host-leave", NULL, gettext_noop ("destroy a place we were hosting"), GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_leave }, - { 'T', "host-announce", NULL, - gettext_noop ("publish something to a place we are hosting"), - GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_announce }, - - { 'e', "guest-enter", NULL, - gettext_noop ("join somebody else's place"), + { 'E', "guest-enter", NULL, + gettext_noop ("enter somebody else's place"), GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_enter }, - { 'g', "guest-reconnect", NULL, - gettext_noop ("reconnect to a previously entered place"), - GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_reconnect }, + { 'F', "look-for", NULL, + gettext_noop ("find state matching name prefix"), + GNUNET_NO, &GNUNET_GETOPT_set_one, &op_look_for }, - { 'd', "guest-leave", NULL, + { 'H', "history-replay-latest", NULL, + gettext_noop ("replay history of latest messages up to the given --limit"), + GNUNET_NO, &GNUNET_GETOPT_set_one, &op_history_replay_latest }, + + { 'L', "guest-leave", NULL, gettext_noop ("leave somebody else's place"), GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_leave }, - { 't', "guest-talk", NULL, - gettext_noop ("submit something to somebody's place"), - GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_talk }, - - { 'R', "history-replay", NULL, - gettext_noop ("replay history of messages between message IDs --start and --end"), - GNUNET_NO, &GNUNET_GETOPT_set_one, &op_history_replay }, + { 'N', "host-reconnect", NULL, + gettext_noop ("reconnect to a previously created place"), + GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_reconnect }, - { 'r', "history-replay-latest", NULL, - gettext_noop ("replay history of latest messages up to the given --limit"), - GNUNET_NO, &GNUNET_GETOPT_set_one, &op_history_replay_latest }, + { 'P', "host-announce", NULL, + gettext_noop ("publish something to a place we are hosting"), + GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_announce }, - { 's', "look-for", NULL, - gettext_noop ("query state matching name prefix"), - GNUNET_NO, &GNUNET_GETOPT_set_one, &op_look_for }, + { 'R', "guest-reconnect", NULL, + gettext_noop ("reconnect to a previously entered place"), + GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_reconnect }, { 'S', "look-at", NULL, - gettext_noop ("query state matching exact name"), + gettext_noop ("search for state matching exact name"), GNUNET_NO, &GNUNET_GETOPT_set_one, &op_look_at }, + { 'T', "guest-talk", NULL, + gettext_noop ("submit something to somebody's place"), + GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_talk }, + + { 'U', "status", NULL, + gettext_noop ("list of egos and subscribed places"), + GNUNET_NO, &GNUNET_GETOPT_set_one, &op_status }, + + { 'X', "history-replay", NULL, + gettext_noop ("extract and replay history between message IDs --start and --end"), + GNUNET_NO, &GNUNET_GETOPT_set_one, &op_history_replay }, + /* options */ - { 'A', "app", "APPLICATION_ID", + { 'a', "app", "APPLICATION_ID", gettext_noop ("application ID to use when connecting"), GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_app }, - { 'p', "place", "PUBKEY", - gettext_noop ("public key of place"), - GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_place }, - - { 'P', "peer", "PEER_ID", - gettext_noop ("peer ID for --guest-enter"), - GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_peer }, - - { 'g', "gns", "ADDRESS", - gettext_noop ("GNS address"), - GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_gns }, + { 'b', "body", "MESSAGE_BODY", + gettext_noop ("message body to transmit"), + GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_body }, - { 'i', "ego", "NAME|PUBKEY", + { 'e', "ego", "NAME|PUBKEY", gettext_noop ("name or public key of ego"), GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_ego }, @@ -1069,37 +1062,45 @@ main (int argc, char *const *argv) gettext_noop ("wait for incoming messages"), GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_follow }, - { 'x', "admit", NULL, - gettext_noop ("respond to entry requests by admitting all guests"), - GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_admit }, + { 'i', "peer", "PEER_ID", + gettext_noop ("peer ID for --guest-enter"), + GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_peer }, - { 'X', "refuse", NULL, - gettext_noop ("respond to entry requests by refusing all guests"), - GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_refuse }, + { 'k', "name", "VAR_NAME", + gettext_noop ("state var name to query"), + GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_name }, + + { 'l', "limit", NULL, + gettext_noop ("number of messages to replay from history"), + GNUNET_YES, &GNUNET_GETOPT_set_ulong, &opt_limit }, { 'm', "method", "METHOD_NAME", gettext_noop ("method name"), GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_method }, - { 'b', "data", "DATA", - gettext_noop ("message body to transmit"), - GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_data }, + { 'n', "gns", "GNS_NAME", + gettext_noop ("GNS name"), + GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_gns }, - { 'k', "name", "VAR_NAME", - gettext_noop ("state var name to query"), - GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_name }, + { 'p', "place", "PUBKEY", + gettext_noop ("public key of place"), + GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_place }, - { 'a', "start", NULL, + { 's', "start", NULL, gettext_noop ("start message ID for history replay"), GNUNET_YES, &GNUNET_GETOPT_set_ulong, &opt_start }, - { 'z', "end", NULL, + { 'w', "welcome", NULL, + gettext_noop ("respond to entry requests by admitting all guests"), + GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_admit }, + + { 'u', "until", NULL, gettext_noop ("end message ID for history replay"), GNUNET_YES, &GNUNET_GETOPT_set_ulong, &opt_end }, - { 'n', "limit", NULL, - gettext_noop ("number of messages to replay from history"), - GNUNET_YES, &GNUNET_GETOPT_set_ulong, &opt_limit }, + { 'y', "deny", NULL, + gettext_noop ("respond to entry requests by refusing all guests"), + GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_refuse }, GNUNET_GETOPT_OPTION_END }; @@ -1115,13 +1116,13 @@ main (int argc, char *const *argv) "gnunet-social --host-enter --ego [--follow] [--admit | --refuse]\n" "gnunet-social --host-reconnect --place [--follow] [--admit | --refuse]\n" "gnunet-social --host-leave --place \n" - "gnunet-social --host-announce --place --method --data \n" + "gnunet-social --host-announce --place --method --body \n" "\n" "gnunet-social --guest-enter --place --peer --ego [--follow]\n" - "gnunet-social --guest-enter --gns --ego [--follow]\n" + "gnunet-social --guest-enter --gns --ego [--follow]\n" "gnunet-social --guest-reconnect --place [--follow]\n" "gnunet-social --guest-leave --place \n" - "gnunet-social --guest-talk --place --method --data \n" + "gnunet-social --guest-talk --place --method --body \n" "\n" "gnunet-social --history-replay --place --start --end [--method ]\n" "gnunet-social --history-replay-latest --place --limit [--method ]\n" -- 2.25.1