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

feat: added usage message replacement feature #786

Merged
merged 4 commits into from
Jan 4, 2023

Conversation

polistern
Copy link
Contributor

@polistern polistern commented Oct 7, 2022

Usage message replacement

Now you able to set custom usage message or pass callback function that will generate it for you.
Example:

CLI::App app{"app v1"};
app.usage("use: [-h|--help] | --option UINT");

Output will be:

app v1
use: [-h|--help] | --option UINT

Options:
  -h,--help                             Show this message

To void usage message replacement in subcommand and be able to get generated usage message just set with empty string:

auto sub = app.add_subcommand("sub");
sub->usage("");

Help message for app -h:

app v1
use: [-h|--help] | --option UINT

Options:
  -h,--help                             Show this message

Subcommands:
sub

Help message for app sub -h:

Usage: app sub [OPTIONS]

Options:
  -h,--help                             Show this message

Footer newline behavior

Moved to #796

@codecov
Copy link

codecov bot commented Oct 8, 2022

Codecov Report

Base: 99.42% // Head: 99.42% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (a6bf0aa) compared to base (c2ea58c).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #786   +/-   ##
=======================================
  Coverage   99.42%   99.42%           
=======================================
  Files          16       16           
  Lines        3977     3989   +12     
=======================================
+ Hits         3954     3966   +12     
  Misses         23       23           
Impacted Files Coverage Δ
include/CLI/App.hpp 100.00% <100.00%> (ø)
include/CLI/impl/App_inl.hpp 99.20% <100.00%> (+<0.01%) ⬆️
include/CLI/impl/Formatter_inl.hpp 99.41% <100.00%> (+0.01%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@phlptp phlptp requested a review from henryiii October 24, 2022 03:19
include/CLI/impl/Formatter_inl.hpp Outdated Show resolved Hide resolved
include/CLI/impl/Formatter_inl.hpp Outdated Show resolved Hide resolved
tests/FormatterTest.cpp Outdated Show resolved Hide resolved
tests/HelpTest.cpp Outdated Show resolved Hide resolved
@polistern polistern changed the title feat: added usage message replacement feature and fixed footer newline behavior feat: added usage message replacement feature Oct 28, 2022
@henryiii henryiii merged commit d350554 into CLIUtils:main Jan 4, 2023
@henryiii
Copy link
Collaborator

henryiii commented Jan 4, 2023

Thanks! Moving on with 2.4.

@github-actions github-actions bot added the needs changelog Hasn't been added to the changelog yet label Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement needs changelog Hasn't been added to the changelog yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants