Closed mtgstuber closed 5 months ago
Attention: 4 lines
in your changes are missing coverage. Please review.
Comparison is base (
ffa8014
) 82.67% compared to head (f453223
) 82.09%.
Files | Patch % | Lines |
---|---|---|
lib/src/embedded_cli.c | 57.14% | 1 Missing and 2 partials :warning: |
examples/linux-example/main.cpp | 0.00% | 1 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This is a bit controversial. Adding extra argument to CliCommandBinding will force all users to provide it always, even if they don't ever need this "hidden" feature. And it's also a breaking change.
Maybe if we make a breaking change anyway, it would be better to change api of binding addition? Like so:
CliCommandBinding* embeddedCliAddBinding(EmbeddedCli *cli, const char* name)
So only command name is a required thing of a binding. And then we set only neccessary fields on returned binding itself:
CliCommandBinding* exit = embeddedCliAddBinding(cli, "exit");
exit->binding = onExit;
CliCommandBinding* quit = embeddedCliAddBinding(cli, "quit");
quit->binding = onExit;
quit->hidden = true;
Another thing that I don't like is that we're spending another byte on this bool value while we already have a tokenizeArgs flag on a binding. So probable, since this is a breaking change anyway, we should remove that flag and add new u8 called flags. And use is as bitflags. Then hidden
can be renamed to autocomplete
(if false, autocompletion not done). And help can be hidden if help string is null.
So tell me what do you think of these suggestions. And tell me if you're willing to add another PR first on all this command binding refactor and then update this PR to use new "binding api".
Closing as stale.
This submission adds an additional "hidden" boolean to the command binding structure. Commands with the "hidden" bit set are not shown in the help menu or provided in autocomplete.
Why have hidden commands? One answer is synonyms. Maybe I want to have "quit" as a synonym to exit without taking up space in the help menu. Another is advanced features: Maybe I want some expert commands that aren't shown to the user.