All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v2 0/3] client: Improve help command
@ 2017-06-19 11:22 ERAMOTO Masaya
  2017-06-19 11:24 ` [PATCH BlueZ v2 1/3] client: Compare a input string and each command only once ERAMOTO Masaya
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: ERAMOTO Masaya @ 2017-06-19 11:22 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: ERAMOTO Masaya, linux-bluetooth

This adds alias-related help messages and makes more readable in whole.

Changes since v1:
 -rebase patches


ERAMOTO Masaya (3):
  client: Compare a input string and each command only once
  client: Add a description to all commands
  client: Output a long message by two lines

 client/main.c | 37 +++++++++++++++++++++++++------------
 1 file changed, 25 insertions(+), 12 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH BlueZ v2 1/3] client: Compare a input string and each command only once
  2017-06-19 11:22 [PATCH BlueZ v2 0/3] client: Improve help command ERAMOTO Masaya
@ 2017-06-19 11:24 ` ERAMOTO Masaya
  2017-06-19 11:25 ` [PATCH BlueZ v2 2/3] client: Add a description to all commands ERAMOTO Masaya
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: ERAMOTO Masaya @ 2017-06-19 11:24 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

This compares a input string and each command only once in rl_handler().

---
 client/main.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/client/main.c b/client/main.c
index 2f269af..784bc69 100644
--- a/client/main.c
+++ b/client/main.c
@@ -1854,6 +1854,8 @@ static void cmd_quit(const char *arg)
 	g_main_loop_quit(main_loop);
 }
 
+static void cmd_help(const char *arg);
+
 static char *generic_generator(const char *text, int state,
 					GList *source, const char *property)
 {
@@ -2145,7 +2147,7 @@ static const struct {
 	{ "version",      NULL,       cmd_version, "Display version" },
 	{ "quit",         NULL,       cmd_quit, "Quit program" },
 	{ "exit",         NULL,       cmd_quit },
-	{ "help" },
+	{ "help",         NULL,       cmd_help },
 	{ }
 };
 
@@ -2245,10 +2247,14 @@ static void rl_handler(char *input)
 		}
 	}
 
-	if (strcmp(cmd, "help")) {
-		printf("Invalid command\n");
-		goto done;
-	}
+	printf("Invalid command\n");
+done:
+	free(input);
+}
+
+static void cmd_help(const char *arg)
+{
+	int i;
 
 	printf("Available commands:\n");
 
@@ -2259,9 +2265,6 @@ static void rl_handler(char *input)
 					cmd_table[i].arg ? : "",
 					cmd_table[i].desc ? : "");
 	}
-
-done:
-	free(input);
 }
 
 static gboolean signal_handler(GIOChannel *channel, GIOCondition condition,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH BlueZ v2 2/3] client: Add a description to all commands
  2017-06-19 11:22 [PATCH BlueZ v2 0/3] client: Improve help command ERAMOTO Masaya
  2017-06-19 11:24 ` [PATCH BlueZ v2 1/3] client: Compare a input string and each command only once ERAMOTO Masaya
@ 2017-06-19 11:25 ` ERAMOTO Masaya
  2017-06-19 11:26 ` [PATCH BlueZ v2 3/3] client: Output a long message by two lines ERAMOTO Masaya
  2017-06-19 11:55 ` [PATCH BlueZ v2 0/3] client: Improve help command Luiz Augusto von Dentz
  3 siblings, 0 replies; 5+ messages in thread
From: ERAMOTO Masaya @ 2017-06-19 11:25 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth


---
 client/main.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/client/main.c b/client/main.c
index 784bc69..3cb4ad5 100644
--- a/client/main.c
+++ b/client/main.c
@@ -2073,8 +2073,10 @@ static const struct {
 	{ "devices",      NULL,       cmd_devices, "List available devices" },
 	{ "paired-devices", NULL,     cmd_paired_devices,
 					"List paired devices"},
-	{ "system-alias", "<name>",   cmd_system_alias },
-	{ "reset-alias",  NULL,       cmd_reset_alias },
+	{ "system-alias", "<name>",   cmd_system_alias,
+					"Set controller alias" },
+	{ "reset-alias",  NULL,       cmd_reset_alias,
+					"Reset controller alias" },
 	{ "power",        "<on/off>", cmd_power, "Set controller power" },
 	{ "pairable",     "<on/off>", cmd_pairable,
 					"Set controller pairable mode" },
@@ -2146,8 +2148,9 @@ static const struct {
 						"Unregister profile" },
 	{ "version",      NULL,       cmd_version, "Display version" },
 	{ "quit",         NULL,       cmd_quit, "Quit program" },
-	{ "exit",         NULL,       cmd_quit },
-	{ "help",         NULL,       cmd_help },
+	{ "exit",         NULL,       cmd_quit, "Quit program" },
+	{ "help",         NULL,       cmd_help,
+					"Display help about this program" },
 	{ }
 };
 
@@ -2259,8 +2262,7 @@ static void cmd_help(const char *arg)
 	printf("Available commands:\n");
 
 	for (i = 0; cmd_table[i].cmd; i++) {
-		if (cmd_table[i].desc)
-			printf("  %s %-*s %s\n", cmd_table[i].cmd,
+		printf("  %s %-*s %s\n", cmd_table[i].cmd,
 					(int)(25 - strlen(cmd_table[i].cmd)),
 					cmd_table[i].arg ? : "",
 					cmd_table[i].desc ? : "");
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH BlueZ v2 3/3] client: Output a long message by two lines
  2017-06-19 11:22 [PATCH BlueZ v2 0/3] client: Improve help command ERAMOTO Masaya
  2017-06-19 11:24 ` [PATCH BlueZ v2 1/3] client: Compare a input string and each command only once ERAMOTO Masaya
  2017-06-19 11:25 ` [PATCH BlueZ v2 2/3] client: Add a description to all commands ERAMOTO Masaya
@ 2017-06-19 11:26 ` ERAMOTO Masaya
  2017-06-19 11:55 ` [PATCH BlueZ v2 0/3] client: Improve help command Luiz Augusto von Dentz
  3 siblings, 0 replies; 5+ messages in thread
From: ERAMOTO Masaya @ 2017-06-19 11:26 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

This outputs the help message by two lines as follows if the string of
a command and a argument is long.

  set-alias <alias>          Set device alias
  select-attribute <attribute/UUID>
                             Select attribute
  attribute-info [attribute/UUID]
                             Select attribute
  read                       Read attribute value

---
 client/main.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/client/main.c b/client/main.c
index 3cb4ad5..578dde9 100644
--- a/client/main.c
+++ b/client/main.c
@@ -2262,10 +2262,18 @@ static void cmd_help(const char *arg)
 	printf("Available commands:\n");
 
 	for (i = 0; cmd_table[i].cmd; i++) {
-		printf("  %s %-*s %s\n", cmd_table[i].cmd,
+		if ((int)strlen(cmd_table[i].arg? : "") <=
+					(int)(25 - strlen(cmd_table[i].cmd)))
+			printf("  %s %-*s %s\n", cmd_table[i].cmd,
 					(int)(25 - strlen(cmd_table[i].cmd)),
 					cmd_table[i].arg ? : "",
 					cmd_table[i].desc ? : "");
+		else
+			printf("  %s %-s\n" "  %s %-25s %s\n",
+					cmd_table[i].cmd,
+					cmd_table[i].arg ? : "",
+					"", "",
+					cmd_table[i].desc ? : "");
 	}
 }
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH BlueZ v2 0/3] client: Improve help command
  2017-06-19 11:22 [PATCH BlueZ v2 0/3] client: Improve help command ERAMOTO Masaya
                   ` (2 preceding siblings ...)
  2017-06-19 11:26 ` [PATCH BlueZ v2 3/3] client: Output a long message by two lines ERAMOTO Masaya
@ 2017-06-19 11:55 ` Luiz Augusto von Dentz
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2017-06-19 11:55 UTC (permalink / raw)
  To: ERAMOTO Masaya; +Cc: linux-bluetooth

Hi Eramoto,

On Mon, Jun 19, 2017 at 2:22 PM, ERAMOTO Masaya
<eramoto.masaya@jp.fujitsu.com> wrote:
> This adds alias-related help messages and makes more readable in whole.
>
> Changes since v1:
>  -rebase patches
>
>
> ERAMOTO Masaya (3):
>   client: Compare a input string and each command only once
>   client: Add a description to all commands
>   client: Output a long message by two lines
>
>  client/main.c | 37 +++++++++++++++++++++++++------------
>  1 file changed, 25 insertions(+), 12 deletions(-)
>
> --
> 2.7.4

Applied, thanks.

-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-06-19 11:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-19 11:22 [PATCH BlueZ v2 0/3] client: Improve help command ERAMOTO Masaya
2017-06-19 11:24 ` [PATCH BlueZ v2 1/3] client: Compare a input string and each command only once ERAMOTO Masaya
2017-06-19 11:25 ` [PATCH BlueZ v2 2/3] client: Add a description to all commands ERAMOTO Masaya
2017-06-19 11:26 ` [PATCH BlueZ v2 3/3] client: Output a long message by two lines ERAMOTO Masaya
2017-06-19 11:55 ` [PATCH BlueZ v2 0/3] client: Improve help command Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.