diff options
author | Carlo von lynX <lynX@time.to.get.psyced.org> | 2016-05-08 10:06:50 +0000 |
---|---|---|
committer | Carlo von lynX <lynX@time.to.get.psyced.org> | 2016-05-08 10:06:50 +0000 |
commit | 11c4dbe993aec1c81310e0c6d72c8bcddbec7496 (patch) | |
tree | e56e4da1c31ceab4c7d6fbc7718502c0f75d4d6e /src/social | |
parent | 932908a83c7be5d6928e4dab794ecb8dff2cbe90 (diff) | |
download | gnunet-11c4dbe993aec1c81310e0c6d72c8bcddbec7496.tar.gz gnunet-11c4dbe993aec1c81310e0c6d72c8bcddbec7496.zip |
cmdline usability for gnunet-social
Diffstat (limited to 'src/social')
-rw-r--r-- | src/social/gnunet-social.c | 147 |
1 files 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; | |||
106 | /** --method */ | 106 | /** --method */ |
107 | static char *opt_method; | 107 | static char *opt_method; |
108 | 108 | ||
109 | /** --data */ | 109 | /** --body */ |
110 | // FIXME: could also come from STDIN | 110 | // FIXME: should come from STDIN |
111 | static char *opt_data; | 111 | static char *opt_body; |
112 | 112 | ||
113 | /** --name */ | 113 | /** --name */ |
114 | static char *opt_name; | 114 | static char *opt_name; |
@@ -255,6 +255,7 @@ static void | |||
255 | guest_leave () | 255 | guest_leave () |
256 | { | 256 | { |
257 | struct GNUNET_PSYC_Environment *env = GNUNET_PSYC_env_create (); | 257 | struct GNUNET_PSYC_Environment *env = GNUNET_PSYC_env_create (); |
258 | // method in the middle of vars? FIXME | ||
258 | GNUNET_PSYC_env_add (env, GNUNET_PSYC_OP_SET, | 259 | GNUNET_PSYC_env_add (env, GNUNET_PSYC_OP_SET, |
259 | "_notice_place_leave", DATA2ARG ("Leaving.")); | 260 | "_notice_place_leave", DATA2ARG ("Leaving.")); |
260 | GNUNET_SOCIAL_guest_leave (gst, env, &guest_left, NULL); | 261 | GNUNET_SOCIAL_guest_leave (gst, env, &guest_left, NULL); |
@@ -735,7 +736,7 @@ host_reconnected (void *cls, int result, | |||
735 | host_leave (); | 736 | host_leave (); |
736 | } | 737 | } |
737 | else if (op_host_announce) { | 738 | else if (op_host_announce) { |
738 | host_announce (opt_method, opt_data, strlen (opt_data)); | 739 | host_announce (opt_method, opt_body, strlen (opt_body)); |
739 | } | 740 | } |
740 | else { | 741 | else { |
741 | place_reconnected (); | 742 | place_reconnected (); |
@@ -755,7 +756,7 @@ guest_reconnected (void *cls, int result, | |||
755 | guest_leave (); | 756 | guest_leave (); |
756 | } | 757 | } |
757 | else if (op_guest_talk) { | 758 | else if (op_guest_talk) { |
758 | guest_talk (opt_method, opt_data, strlen (opt_data)); | 759 | guest_talk (opt_method, opt_body, strlen (opt_body)); |
759 | } | 760 | } |
760 | else { | 761 | else { |
761 | place_reconnected (); | 762 | place_reconnected (); |
@@ -919,8 +920,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
919 | 920 | ||
920 | if (!opt_method) | 921 | if (!opt_method) |
921 | opt_method = "message"; | 922 | opt_method = "message"; |
922 | if (!opt_data) | 923 | if (!opt_body) |
923 | opt_data = ""; | 924 | opt_body = ""; |
924 | if (!opt_name) | 925 | if (!opt_name) |
925 | opt_name = ""; | 926 | opt_name = ""; |
926 | 927 | ||
@@ -990,78 +991,70 @@ main (int argc, char *const *argv) | |||
990 | 991 | ||
991 | /* operations */ | 992 | /* operations */ |
992 | 993 | ||
993 | { 'u', "status", NULL, | 994 | { 'C', "host-enter", NULL, |
994 | gettext_noop ("list of egos and subscribed places"), | ||
995 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_status }, | ||
996 | |||
997 | { 'E', "host-enter", NULL, | ||
998 | gettext_noop ("create a place"), | 995 | gettext_noop ("create a place"), |
999 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_enter }, | 996 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_enter }, |
1000 | 997 | ||
1001 | { 'H', "host-reconnect", NULL, | ||
1002 | gettext_noop ("reconnect to a previously created place"), | ||
1003 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_reconnect }, | ||
1004 | |||
1005 | { 'D', "host-leave", NULL, | 998 | { 'D', "host-leave", NULL, |
1006 | gettext_noop ("destroy a place we were hosting"), | 999 | gettext_noop ("destroy a place we were hosting"), |
1007 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_leave }, | 1000 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_leave }, |
1008 | 1001 | ||
1009 | { 'T', "host-announce", NULL, | 1002 | { 'E', "guest-enter", NULL, |
1010 | gettext_noop ("publish something to a place we are hosting"), | 1003 | gettext_noop ("enter somebody else's place"), |
1011 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_announce }, | ||
1012 | |||
1013 | { 'e', "guest-enter", NULL, | ||
1014 | gettext_noop ("join somebody else's place"), | ||
1015 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_enter }, | 1004 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_enter }, |
1016 | 1005 | ||
1017 | { 'g', "guest-reconnect", NULL, | 1006 | { 'F', "look-for", NULL, |
1018 | gettext_noop ("reconnect to a previously entered place"), | 1007 | gettext_noop ("find state matching name prefix"), |
1019 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_reconnect }, | 1008 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_look_for }, |
1020 | 1009 | ||
1021 | { 'd', "guest-leave", NULL, | 1010 | { 'H', "history-replay-latest", NULL, |
1011 | gettext_noop ("replay history of latest messages up to the given --limit"), | ||
1012 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_history_replay_latest }, | ||
1013 | |||
1014 | { 'L', "guest-leave", NULL, | ||
1022 | gettext_noop ("leave somebody else's place"), | 1015 | gettext_noop ("leave somebody else's place"), |
1023 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_leave }, | 1016 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_leave }, |
1024 | 1017 | ||
1025 | { 't', "guest-talk", NULL, | 1018 | { 'N', "host-reconnect", NULL, |
1026 | gettext_noop ("submit something to somebody's place"), | 1019 | gettext_noop ("reconnect to a previously created place"), |
1027 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_talk }, | 1020 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_reconnect }, |
1028 | |||
1029 | { 'R', "history-replay", NULL, | ||
1030 | gettext_noop ("replay history of messages between message IDs --start and --end"), | ||
1031 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_history_replay }, | ||
1032 | 1021 | ||
1033 | { 'r', "history-replay-latest", NULL, | 1022 | { 'P', "host-announce", NULL, |
1034 | gettext_noop ("replay history of latest messages up to the given --limit"), | 1023 | gettext_noop ("publish something to a place we are hosting"), |
1035 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_history_replay_latest }, | 1024 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_host_announce }, |
1036 | 1025 | ||
1037 | { 's', "look-for", NULL, | 1026 | { 'R', "guest-reconnect", NULL, |
1038 | gettext_noop ("query state matching name prefix"), | 1027 | gettext_noop ("reconnect to a previously entered place"), |
1039 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_look_for }, | 1028 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_reconnect }, |
1040 | 1029 | ||
1041 | { 'S', "look-at", NULL, | 1030 | { 'S', "look-at", NULL, |
1042 | gettext_noop ("query state matching exact name"), | 1031 | gettext_noop ("search for state matching exact name"), |
1043 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_look_at }, | 1032 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_look_at }, |
1044 | 1033 | ||
1034 | { 'T', "guest-talk", NULL, | ||
1035 | gettext_noop ("submit something to somebody's place"), | ||
1036 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_guest_talk }, | ||
1037 | |||
1038 | { 'U', "status", NULL, | ||
1039 | gettext_noop ("list of egos and subscribed places"), | ||
1040 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_status }, | ||
1041 | |||
1042 | { 'X', "history-replay", NULL, | ||
1043 | gettext_noop ("extract and replay history between message IDs --start and --end"), | ||
1044 | GNUNET_NO, &GNUNET_GETOPT_set_one, &op_history_replay }, | ||
1045 | |||
1045 | 1046 | ||
1046 | /* options */ | 1047 | /* options */ |
1047 | 1048 | ||
1048 | { 'A', "app", "APPLICATION_ID", | 1049 | { 'a', "app", "APPLICATION_ID", |
1049 | gettext_noop ("application ID to use when connecting"), | 1050 | gettext_noop ("application ID to use when connecting"), |
1050 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_app }, | 1051 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_app }, |
1051 | 1052 | ||
1052 | { 'p', "place", "PUBKEY", | 1053 | { 'b', "body", "MESSAGE_BODY", |
1053 | gettext_noop ("public key of place"), | 1054 | gettext_noop ("message body to transmit"), |
1054 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_place }, | 1055 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_body }, |
1055 | |||
1056 | { 'P', "peer", "PEER_ID", | ||
1057 | gettext_noop ("peer ID for --guest-enter"), | ||
1058 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_peer }, | ||
1059 | |||
1060 | { 'g', "gns", "ADDRESS", | ||
1061 | gettext_noop ("GNS address"), | ||
1062 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_gns }, | ||
1063 | 1056 | ||
1064 | { 'i', "ego", "NAME|PUBKEY", | 1057 | { 'e', "ego", "NAME|PUBKEY", |
1065 | gettext_noop ("name or public key of ego"), | 1058 | gettext_noop ("name or public key of ego"), |
1066 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_ego }, | 1059 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_ego }, |
1067 | 1060 | ||
@@ -1069,37 +1062,45 @@ main (int argc, char *const *argv) | |||
1069 | gettext_noop ("wait for incoming messages"), | 1062 | gettext_noop ("wait for incoming messages"), |
1070 | GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_follow }, | 1063 | GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_follow }, |
1071 | 1064 | ||
1072 | { 'x', "admit", NULL, | 1065 | { 'i', "peer", "PEER_ID", |
1073 | gettext_noop ("respond to entry requests by admitting all guests"), | 1066 | gettext_noop ("peer ID for --guest-enter"), |
1074 | GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_admit }, | 1067 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_peer }, |
1075 | 1068 | ||
1076 | { 'X', "refuse", NULL, | 1069 | { 'k', "name", "VAR_NAME", |
1077 | gettext_noop ("respond to entry requests by refusing all guests"), | 1070 | gettext_noop ("state var name to query"), |
1078 | GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_refuse }, | 1071 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_name }, |
1072 | |||
1073 | { 'l', "limit", NULL, | ||
1074 | gettext_noop ("number of messages to replay from history"), | ||
1075 | GNUNET_YES, &GNUNET_GETOPT_set_ulong, &opt_limit }, | ||
1079 | 1076 | ||
1080 | { 'm', "method", "METHOD_NAME", | 1077 | { 'm', "method", "METHOD_NAME", |
1081 | gettext_noop ("method name"), | 1078 | gettext_noop ("method name"), |
1082 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_method }, | 1079 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_method }, |
1083 | 1080 | ||
1084 | { 'b', "data", "DATA", | 1081 | { 'n', "gns", "GNS_NAME", |
1085 | gettext_noop ("message body to transmit"), | 1082 | gettext_noop ("GNS name"), |
1086 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_data }, | 1083 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_gns }, |
1087 | 1084 | ||
1088 | { 'k', "name", "VAR_NAME", | 1085 | { 'p', "place", "PUBKEY", |
1089 | gettext_noop ("state var name to query"), | 1086 | gettext_noop ("public key of place"), |
1090 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_name }, | 1087 | GNUNET_YES, &GNUNET_GETOPT_set_string, &opt_place }, |
1091 | 1088 | ||
1092 | { 'a', "start", NULL, | 1089 | { 's', "start", NULL, |
1093 | gettext_noop ("start message ID for history replay"), | 1090 | gettext_noop ("start message ID for history replay"), |
1094 | GNUNET_YES, &GNUNET_GETOPT_set_ulong, &opt_start }, | 1091 | GNUNET_YES, &GNUNET_GETOPT_set_ulong, &opt_start }, |
1095 | 1092 | ||
1096 | { 'z', "end", NULL, | 1093 | { 'w', "welcome", NULL, |
1094 | gettext_noop ("respond to entry requests by admitting all guests"), | ||
1095 | GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_admit }, | ||
1096 | |||
1097 | { 'u', "until", NULL, | ||
1097 | gettext_noop ("end message ID for history replay"), | 1098 | gettext_noop ("end message ID for history replay"), |
1098 | GNUNET_YES, &GNUNET_GETOPT_set_ulong, &opt_end }, | 1099 | GNUNET_YES, &GNUNET_GETOPT_set_ulong, &opt_end }, |
1099 | 1100 | ||
1100 | { 'n', "limit", NULL, | 1101 | { 'y', "deny", NULL, |
1101 | gettext_noop ("number of messages to replay from history"), | 1102 | gettext_noop ("respond to entry requests by refusing all guests"), |
1102 | GNUNET_YES, &GNUNET_GETOPT_set_ulong, &opt_limit }, | 1103 | GNUNET_NO, &GNUNET_GETOPT_set_one, &opt_refuse }, |
1103 | 1104 | ||
1104 | GNUNET_GETOPT_OPTION_END | 1105 | GNUNET_GETOPT_OPTION_END |
1105 | }; | 1106 | }; |
@@ -1115,13 +1116,13 @@ main (int argc, char *const *argv) | |||
1115 | "gnunet-social --host-enter --ego <NAME or PUBKEY> [--follow] [--admit | --refuse]\n" | 1116 | "gnunet-social --host-enter --ego <NAME or PUBKEY> [--follow] [--admit | --refuse]\n" |
1116 | "gnunet-social --host-reconnect --place <PUBKEY> [--follow] [--admit | --refuse]\n" | 1117 | "gnunet-social --host-reconnect --place <PUBKEY> [--follow] [--admit | --refuse]\n" |
1117 | "gnunet-social --host-leave --place <PUBKEY>\n" | 1118 | "gnunet-social --host-leave --place <PUBKEY>\n" |
1118 | "gnunet-social --host-announce --place <PUBKEY> --method <METHOD_NAME> --data <MESSAGE BODY>\n" | 1119 | "gnunet-social --host-announce --place <PUBKEY> --method <METHOD_NAME> --body <MESSAGE_BODY>\n" |
1119 | "\n" | 1120 | "\n" |
1120 | "gnunet-social --guest-enter --place <PUBKEY> --peer <PEERID> --ego <NAME or PUBKEY> [--follow]\n" | 1121 | "gnunet-social --guest-enter --place <PUBKEY> --peer <PEERID> --ego <NAME or PUBKEY> [--follow]\n" |
1121 | "gnunet-social --guest-enter --gns <GNS_ADDRESS> --ego <NAME or PUBKEY> [--follow]\n" | 1122 | "gnunet-social --guest-enter --gns <GNS_NAME> --ego <NAME or PUBKEY> [--follow]\n" |
1122 | "gnunet-social --guest-reconnect --place <PUBKEY> [--follow]\n" | 1123 | "gnunet-social --guest-reconnect --place <PUBKEY> [--follow]\n" |
1123 | "gnunet-social --guest-leave --place <PUBKEY>\n" | 1124 | "gnunet-social --guest-leave --place <PUBKEY>\n" |
1124 | "gnunet-social --guest-talk --place <PUBKEY> --method <METHOD_NMAE> --data <DATA>\n" | 1125 | "gnunet-social --guest-talk --place <PUBKEY> --method <METHOD_NAME> --body <MESSAGE_BODY>\n" |
1125 | "\n" | 1126 | "\n" |
1126 | "gnunet-social --history-replay --place <PUBKEY> --start <MSGID> --end <MSGID> [--method <METHOD_PREFIX>]\n" | 1127 | "gnunet-social --history-replay --place <PUBKEY> --start <MSGID> --end <MSGID> [--method <METHOD_PREFIX>]\n" |
1127 | "gnunet-social --history-replay-latest --place <PUBKEY> --limit <MSG_LIMIT> [--method <METHOD_PREFIX>]\n" | 1128 | "gnunet-social --history-replay-latest --place <PUBKEY> --limit <MSG_LIMIT> [--method <METHOD_PREFIX>]\n" |