Skip to content
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

Update the help system to avoid orphan commands #168

Open
DangerousPrototypes opened this issue Dec 19, 2024 · 1 comment
Open

Update the help system to avoid orphan commands #168

DangerousPrototypes opened this issue Dec 19, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@DangerousPrototypes
Copy link
Owner

const struct ui_help_options global_commands[] = {
    { 1, "", T_HELP_SECTION_IO }, // work with pins, input, output measurement
    { 0, "w/W", T_HELP_1_21 },    // note that pin functions need power on the buffer
    { 0, "a/A/@ x", T_HELP_COMMAND_AUX },
    { 0, "f x/F x", T_HELP_1_11 },
    { 0, "f/F", T_HELP_1_23 },
    { 0, "g x/G", T_HELP_1_12 },
    { 0, "p/P", T_HELP_1_18 },
    { 0, "v x/V x", T_HELP_1_22 },
    { 0, "v/V", T_HELP_1_10 },

Currently the help menu is hand crafted for a nice look, but results in orphan commands that were added to the firmware without a help entry.

// command configuration
const struct _global_command_struct commands[] = {
    // clang-format off
{ .command="ls",    .allow_hiz=true, .func=&disk_ls_handler, .help_text=0x00 }, // ls T_CMDLN_LS
{ .command="cd",    .allow_hiz=true, .func=&disk_cd_handler, .help_text=0x00 }, // cd T_CMDLN_CD
{ .command="mkdir", .allow_hiz=true, .func=&disk_mkdir_handler, .help_text=0x00 }, // mkdir T_CMDLN_MKDIR
{ .command="rm",    .allow_hiz=true, .func=&disk_rm_handler, .help_text=0x00 }, // rm T_CMDLN_RM

I propose adding a few additional fields to the commands struct to enforce complete listings in the help output and automate the organization under topic headings.

  • Help text T_HELP_ would be moved from global_commands to commands struct
  • Command examples (w/W, a/A/@ x) would move to the command struct. The reason for this is that some commands have a customized/combined display that covers multiple commands in a single line, such as Aux or poWer.
  • A new field that references a topic header ID in a new array. The help would iterate over the topics ID array, looping though the command struct and printing the help for any assigned commands.

This still isn't perfect, but it does consolidate all the help into the place where you have to tie in the command anyways.

@DangerousPrototypes DangerousPrototypes added the enhancement New feature or request label Dec 19, 2024
@DangerousPrototypes
Copy link
Owner Author

struct ui_help_topics {
    uint8_t topic_id;
    const char* description;
};

enum {
    HELP_TOPIC_IO = 0,
    HELP_TOPIC_CONFIGURE,
    HELP_TOPIC_SYSTEM,
    HELP_TOPIC_FILES,
    HELP_TOPIC_SCRIPT,
    HELP_TOPIC_TOOLS,
    HELP_TOPIC_MODE,
    HELP_TOPIC_SYNTAX,
};

const struct ui_help_topics help_topics[] = {
    { HELP_TOPIC_IO, T_HELP_SECTION_IO},
    { HELP_TOPIC_CONFIGURE, T_HELP_SECTION_CONFIGURE},
    { HELP_TOPIC_SYSTEM, T_HELP_SECTION_SYSTEM},
    { HELP_TOPIC_FILES, T_HELP_SECTION_FILES},
    { HELP_TOPIC_SCRIPT, T_HELP_SECTION_SCRIPT},
    { HELP_TOPIC_TOOLS, T_HELP_SECTION_TOOLS},
    { HELP_TOPIC_MODE, T_HELP_SECTION_MODE},
    { HELP_TOPIC_SYNTAX, T_HELP_SECTION_SYNTAX},
};

Topics struct.

// command configuration
const struct _global_command_struct commands[] = {
    // clang-format off
{ .command="ls",    .allow_hiz=true, .func=&disk_ls_handler, .help_text=0x00, .help_topic=HELP_TOPIC_FILES, .help_description=T_HELP_CMD_LS },

Extending the command struct. Still now quite there, but this is the idea.

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

No branches or pull requests

1 participant