Skip to contentSkip to conversation

shared/shell: Print help info for individual commands

PATCH Applied Inga Stotland 3 participants 3 messages May 13, 2021 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 shared/shell: Print help info for individual commands

For menus with long list of entries, it is useful to be able invoke help message for an individual entry to look up command description and synopsis.
Can be invoked by entering "<command> help" or "<command> --help".

---
 src/shared/shell.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
src/shared/shell.c +10 -0
index c0de1640d..07eaa1702 100644
@@ -352,6 +352,16 @@ static int cmd_exec(const struct bt_shell_menu_entry *entry,
 	int flags = WRDE_NOCMD;
 	bool optargs = false;
 
+	if (argc == 2 && (!memcmp(argv[1], "help", 4) ||
+				!memcmp(argv[1], "--help", 6))) {
+		printf("%s\n", entry->desc);
+		printf(COLOR_HIGHLIGHT "Usage:" COLOR_OFF "\n");
+		printf("\t %s %-*s\n", entry->cmd,
+				(int)(CMD_LENGTH - strlen(entry->cmd)),
+					!entry->arg ? "" : entry->arg);
+		return 0;
+	}
+
 	if (!entry->arg || entry->arg[0] == '\0') {
 		if (argc > 1) {
 			print_text(COLOR_HIGHLIGHT, "Too many arguments");
Signature · 1 line
2.26.3
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=481581

---Test result---

Test Summary:

CheckPatch                    PASS      0.53 seconds
GitLint                       PASS      0.14 seconds
Prep - Setup ELL              PASS      40.14 seconds
Build - Prep                  PASS      0.10 seconds
Build - Configure             PASS      7.03 seconds
Build - Make                  PASS      167.38 seconds
Make Check                    PASS      8.21 seconds
Make Distcheck                PASS      190.10 seconds
Build w/ext ELL - Configure   PASS      6.57 seconds
Build w/ext ELL - Make        PASS      148.17 seconds

Details
##############################
Test: CheckPatch - PASS
Desc: Run checkpatch.pl script with rule in .checkpatch.conf

##############################
Test: GitLint - PASS
Desc: Run gitlint with rule in .gitlint

##############################
Test: Prep - Setup ELL - PASS
Desc: Clone, build, and install ELL

##############################
Test: Build - Prep - PASS
Desc: Prepare environment for build

##############################
Test: Build - Configure - PASS
Desc: Configure the BlueZ source tree

##############################
Test: Build - Make - PASS
Desc: Build the BlueZ source tree

##############################
Test: Make Check - PASS
Desc: Run 'make check'

##############################
Test: Make Distcheck - PASS
Desc: Run distcheck to check the distribution

##############################
Test: Build w/ext ELL - Configure - PASS
Desc: Configure BlueZ source with '--enable-external-ell' configuration

##############################
Test: Build w/ext ELL - Make - PASS
Desc: Build BlueZ source with '--enable-external-ell' configuration

---
Regards,
Linux Bluetooth

maintainer Applied
#2 lore raw

Hi Inga,

Quoted 66 lines · On Wed, May 12, 2021 at 6:45 PM <[email protected]> wrote:

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=481581

---Test result---

Test Summary:

CheckPatch                    PASS      0.53 seconds
GitLint                       PASS      0.14 seconds
Prep - Setup ELL              PASS      40.14 seconds
Build - Prep                  PASS      0.10 seconds
Build - Configure             PASS      7.03 seconds
Build - Make                  PASS      167.38 seconds
Make Check                    PASS      8.21 seconds
Make Distcheck                PASS      190.10 seconds
Build w/ext ELL - Configure   PASS      6.57 seconds
Build w/ext ELL - Make        PASS      148.17 seconds

Details
##############################
Test: CheckPatch - PASS
Desc: Run checkpatch.pl script with rule in .checkpatch.conf

##############################
Test: GitLint - PASS
Desc: Run gitlint with rule in .gitlint

##############################
Test: Prep - Setup ELL - PASS
Desc: Clone, build, and install ELL

##############################
Test: Build - Prep - PASS
Desc: Prepare environment for build

##############################
Test: Build - Configure - PASS
Desc: Configure the BlueZ source tree

##############################
Test: Build - Make - PASS
Desc: Build the BlueZ source tree

##############################
Test: Make Check - PASS
Desc: Run 'make check'

##############################
Test: Make Distcheck - PASS
Desc: Run distcheck to check the distribution

##############################
Test: Build w/ext ELL - Configure - PASS
Desc: Configure BlueZ source with '--enable-external-ell' configuration

##############################
Test: Build w/ext ELL - Make - PASS
Desc: Build BlueZ source with '--enable-external-ell' configuration

Quoted 3 lines

---
Regards,
Linux Bluetooth

Applied, thanks.

Signature · 1 line
Luiz Augusto von Dentz