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

Silent subcommands #529

Merged
merged 1 commit into from
Dec 28, 2020
Merged

Silent subcommands #529

merged 1 commit into from
Dec 28, 2020

Conversation

phlptp
Copy link
Collaborator

@phlptp phlptp commented Oct 22, 2020

add a silent option to subcommands to prevent the use from showing up in the subcommands list if used.

This is in response to Issue #522.

Adds an ability to silence subcommands and prevent them from showing up in the used subcommands list.
This allows things like

    auto sub1 = app.add_subcommand("help")->silent();
    sub1->parse_complete_callback([]() { throw CLI::CallForHelp(); });

@codecov
Copy link

codecov bot commented Oct 22, 2020

Codecov Report

Merging #529 (3c0f6fc) into master (ff55758) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #529   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           12        12           
  Lines         3766      3772    +6     
=========================================
+ Hits          3766      3772    +6     
Impacted Files Coverage Δ
include/CLI/App.hpp 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3bf24c5...3c0f6fc. Read the comment docs.


/// indicator that the subcommand is silent and won't show up in subcommands list
/// This is potentially useful as a modifier subcommand
bool silent_{false};
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be moved up to be with the other 8-bit members; if bools are placed together the compiler is more likely to pack them into 8 bits each, rather than adding alignment spacing. Technically, we probably should try to order the struct members large to small, but optimizing this is not really that important - it's just nice to do it right when we add something.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was trying to put it into a gap in alignment, I rearranged a bit

Comment on lines 2393 to 2411
void _parse_config(const std::vector<ConfigItem> &args) {
for(const ConfigItem &item : args) {
void _parse_config(std::vector<ConfigItem> &args) {
for(ConfigItem item : args) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why this change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

recommended by clang-tidy or some other static analysis tools I ran

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am going to change it back, it might have been a merge conflict or something

@phlptp phlptp force-pushed the silent_subcommands branch 2 times, most recently from fe7dfdd to a43597b Compare November 25, 2020 17:42
… in the subcommands list if used.

Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
@phlptp
Copy link
Collaborator Author

phlptp commented Nov 25, 2020

I think this is ready now @henryiii
I also upgraded a version number with the cuda build for a github change

@henryiii henryiii merged commit f046152 into CLIUtils:master Dec 28, 2020
@henryiii henryiii deleted the silent_subcommands branch December 28, 2020 16:00
@github-actions github-actions bot added the needs changelog Hasn't been added to the changelog yet label Dec 28, 2020
@henryiii henryiii added this to the v2.0 milestone Jun 24, 2021
@henryiii henryiii removed the needs changelog Hasn't been added to the changelog yet label Jul 1, 2021
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