Skip to content

Add help menu to CommonCLI.cpp #635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

yg-ht
Copy link

@yg-ht yg-ht commented Aug 17, 2025

I keep wanting a help menu in the CLI but it isn't there. Had a look and realised a small refactor would help make this maintainable. I have:

  • made a single source of truth for the output strings
  • added a number of formatter functions to enable small help responses (essentially grouped things)
  • added the calling routines for the above into the main logic

CLI message responses for use over the mesh need to be <= 160 chars which I think I have achieved here. Needed to group things so that it didn't just try to dump everything in one hit and go way over that 160 limit. Was also conscious of future expansion so I hope these messages are still small enough for additional options in the future.

I believe this is a direct drop-in with no other files / code affected. This is first commit after development though and has not yet been tested on a device. Please can I ask for help on this as it might take me a bit to actually test it (I am away from devices right now).

I keep wanting a help menu in the CLI but it isn't there.  Had a look and realised a small refactor would help make this maintainable.  I have:

- made a single source of truth for the output strings
- added a number of formatter functions to enable small help responses (essentially grouped things)
- added the calling routines for the above into the main logic

CLI message responses for use over the mesh need to be <= 160 chars which I *think* I have achieved here.  Needed to group things so that it didn't just try to dump everything in one hit and go way over that 160 limit.  Was also conscious of future expansion so I hope these messages are still small enough for additional options in the future.

I believe this is a direct drop-in with no other files / code affected.  This is first commit after development though and has not yet been tested on a device.
@yg-ht yg-ht changed the title Update CommonCLI.cpp Add help menu toUpdate CommonCLI.cpp Aug 17, 2025
@yg-ht yg-ht changed the title Add help menu toUpdate CommonCLI.cpp Add help menu to CommonCLI.cpp Aug 17, 2025
Copy link

@4np 4np left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to have help! I was constantly looking for this as well :)

if (memcmp(command, CMD_HELP, 4) == 0) {
if (memcmp(command, "help device cmds", 16) == 0) { format_help_device_cmds(reply); return; }
if (memcmp(command, "help device keys", 16) == 0) { format_help_device_keys(reply); return; }
if (memcmp(command, "help radio cmds", 15) == 0) { format_help_radio_cmds(reply); return; }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would probably make sense to use the constants here as well, something like:

Suggested change
if (memcmp(command, "help radio cmds", 15) == 0) { format_help_radio_cmds(reply); return; }
if (memcmp(command, CMD_HELP + SPACE + KEY_RADIO + "cmds", 15) == 0) { format_help_radio_cmds(reply); return; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants