diff mbox series

[4/8] client: add developer mode option (-E)

Message ID 20220810231621.372514-4-prestwoj@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show
Series [1/8] network: make network const in network_bss_list_get_entries | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-gitlint success GitLint

Commit Message

James Prestwood Aug. 10, 2022, 11:16 p.m. UTC
This puts iwctl into developer mode which allows IWD debug interfaces
to be used.
---
 client/command.c | 26 ++++++++++++++++++--------
 client/command.h |  1 +
 2 files changed, 19 insertions(+), 8 deletions(-)

Comments

Denis Kenzior Aug. 11, 2022, 2:40 p.m. UTC | #1
Hi James,

On 8/10/22 18:16, James Prestwood wrote:
> This puts iwctl into developer mode which allows IWD debug interfaces
> to be used.

Why is this needed?  Can't you just detect that iwd made Debug interfaces 
available and enable these automagically?

> ---
>   client/command.c | 26 ++++++++++++++++++--------
>   client/command.h |  1 +
>   2 files changed, 19 insertions(+), 8 deletions(-)
> 

Regards,
-Denis
diff mbox series

Patch

diff --git a/client/command.c b/client/command.c
index c0576e97..80599620 100644
--- a/client/command.c
+++ b/client/command.c
@@ -38,6 +38,7 @@  static struct l_queue *command_families;
 static struct l_queue *command_options;
 static int exit_status;
 static bool interactive_mode;
+static bool developer_mode;
 static struct command_noninteractive {
 	char **argv;
 	int argc;
@@ -616,6 +617,11 @@  bool command_is_interactive_mode(void)
 	return interactive_mode;
 }
 
+bool command_is_developer_mode(void)
+{
+	return developer_mode;
+}
+
 void command_set_exit_status(int status)
 {
 	exit_status = status;
@@ -657,6 +663,7 @@  static const struct option command_opts[] = {
 	{ COMMAND_OPTION_PASSPHRASE,	required_argument, NULL, 'P' },
 	{ COMMAND_OPTION_DONTASK,	no_argument,	   NULL, 'd' },
 	{ "help",			no_argument,	   NULL, 'h' },
+	{ "developer",			no_argument,	   NULL, 'E' },
 	{ }
 };
 
@@ -671,17 +678,10 @@  bool command_init(char **argv, int argc)
 	command_families = l_queue_new();
 	command_options = l_queue_new();
 
-	for (desc = __start___command; desc < __stop___command; desc++) {
-		if (!desc->init)
-			continue;
-
-		desc->init();
-	}
-
 	for (;;) {
 		struct command_option *option;
 
-		opt = getopt_long(argc, argv, "u:p:P:dh", command_opts, NULL);
+		opt = getopt_long(argc, argv, "u:p:P:dhE", command_opts, NULL);
 
 		switch (opt) {
 		case 'u':
@@ -714,6 +714,9 @@  bool command_init(char **argv, int argc)
 
 			l_queue_push_tail(command_options, option);
 
+			break;
+		case 'E':
+			developer_mode = true;
 			break;
 		case 'h':
 			command_display_help();
@@ -731,6 +734,13 @@  bool command_init(char **argv, int argc)
 	}
 
 options_parsed:
+	for (desc = __start___command; desc < __stop___command; desc++) {
+		if (!desc->init)
+			continue;
+
+		desc->init();
+	}
+
 	argv += optind;
 	argc -= optind;
 
diff --git a/client/command.h b/client/command.h
index 23f23dc9..bdfc7e99 100644
--- a/client/command.h
+++ b/client/command.h
@@ -69,6 +69,7 @@  void command_process_prompt(char **argv, int argc);
 
 void command_noninteractive_trigger(void);
 bool command_is_interactive_mode(void);
+bool command_is_developer_mode(void);
 int command_get_exit_status(void);
 void command_set_exit_status(int status);
 void command_reset_default_entities(void);