eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

commit 79ccff464fcb6abd4a8719a3f192600cfd4f64a2
parent d369a650ab59cb03c8230d9dfefa9a7c0010f921
Author: Tim Kourt <tim.a.kourt@linux.intel.com>
Date:   Wed, 18 Sep 2019 15:18:35 -0700

client: Provide '--help' command-line option

In addition, this improves the 'help' display

Diffstat:
Mclient/command.c | 53+++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 45 insertions(+), 8 deletions(-)

diff --git a/client/command.c b/client/command.c @@ -506,6 +506,20 @@ static void list_commands(const char *command_family, } } +static void list_cmd_options(void) +{ + display(MARGIN "--%-*s%s\n", 48, COMMAND_OPTION_USERNAME, + "Provide username"); + display(MARGIN "--%-*s%s\n", 48, COMMAND_OPTION_PASSWORD, + "Provide password"); + display(MARGIN "--%-*s%s\n", 48, COMMAND_OPTION_PASSPHRASE, + "Provide passphrase"); + display(MARGIN "--%-*s%s\n", 48, COMMAND_OPTION_DONTASK, + "Don’t ask for missing\n" + "\t\t\t\t\t\t credentials"); + display(MARGIN "--%-*s%s\n", 48, "help", "Display help"); +} + static void list_cmd_families(void) { const struct l_queue_entry *entry; @@ -519,25 +533,41 @@ static void list_cmd_families(void) } } -static bool command_match_misc_commands(char **argv, int argc) +static void command_display_help(void) { - if (match_cmd(NULL, argv[0], argv + 1, argc - 1, misc_commands)) - return true; + display("\n"); + display_table_header("iwctl version " VERSION, MARGIN "%-*s", + 5, "Usage"); + display(MARGIN "iwctl [--options] [commands]\n"); + display_table_footer(); - if (strcmp(argv[0], "help")) - return false; + display_table_header("Available options", MARGIN "%-*s%-*s", + 50, "Options", 28, "Description"); + list_cmd_options(); + display_table_footer(); display_table_header("Available commands", MARGIN "%-*s%-*s", 50, "Commands", 28, "Description"); - list_cmd_families(); + display_table_footer(); if (!interactive_mode) - return true; + return; display("\nMiscellaneous:\n"); list_commands(NULL, misc_commands); +} + +static bool command_match_misc_commands(char **argv, int argc) +{ + if (match_cmd(NULL, argv[0], argv + 1, argc - 1, misc_commands)) + return true; + + if (strcmp(argv[0], "help")) + return false; + + command_display_help(); return true; } @@ -625,6 +655,7 @@ static const struct option command_opts[] = { { COMMAND_OPTION_PASSWORD, required_argument, NULL, 'p' }, { COMMAND_OPTION_PASSPHRASE, required_argument, NULL, 'P' }, { COMMAND_OPTION_DONTASK, no_argument, NULL, 'd' }, + { "help", no_argument, NULL, 'h' }, { } }; @@ -649,7 +680,7 @@ bool command_init(char **argv, int argc) for (;;) { struct command_option *option; - opt = getopt_long(argc, argv, "u:p:P:d", command_opts, NULL); + opt = getopt_long(argc, argv, "u:p:P:dh", command_opts, NULL); switch (opt) { case 'u': @@ -683,6 +714,12 @@ bool command_init(char **argv, int argc) l_queue_push_tail(command_options, option); break; + case 'h': + command_display_help(); + + l_main_quit(); + + return true; case -1: goto options_parsed; case '?':