Skip to content

Deprecated retired options - #358

Merged
henryiii merged 11 commits into
CLIUtils:masterfrom
phlptp:deprecated_retired_options
Dec 5, 2019
Merged

henryiii merged 11 commits into
CLIUtils:masterfrom
phlptp:deprecated_retired_options

Conversation

@phlptp

@phlptp phlptp commented Dec 1, 2019

Copy link
Copy Markdown
Collaborator

adds helper functions for retired and deprecated options

Fixes #275

@phlptp

phlptp commented Dec 1, 2019 •

Copy link
Copy Markdown
Collaborator Author

TODO

  • add documentation
  • add some comments and explanation to the example
  • verify code coverage
  • rename a few variable
  • verify coverage

@codecov

codecov Bot commented Dec 1, 2019 •

Copy link
Copy Markdown

Codecov Report

Merging #358 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #358   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          12     12           
  Lines        3353   3396   +43     
=====================================
+ Hits         3353   3396   +43
Impacted Files Coverage Δ
include/CLI/Option.hpp 100% <100%> (ø) ⬆️
include/CLI/App.hpp 100% <100%> (ø) ⬆️

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 ba7b29f...c326f73. Read the comment docs.

@phlptp phlptp changed the title [WIP] Deprecated retired options Deprecated retired options Dec 3, 2019

@cbachhuber cbachhuber left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for this addition! Looks very good already, I only have minor remarks.

Comment thread examples/retired.cpp Resolved
Comment thread examples/retired.cpp Resolved
Comment thread examples/retired.cpp Resolved
Comment thread examples/retired.cpp Resolved
Comment thread examples/retired.cpp
// deprecate an existing option and specify a recommended replacement
CLI::deprecate_option(opt2, "--not_deprecated");

CLI11_PARSE(app, argc, argv);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Many other examples do a std::cout at the end, to show what is going on. Does that make sense here as well?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Maybe something that prints out if the '--not_deprecated` or no options were passed, just so there is always guaranteed to be some output?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good suggestion, I like it!

Comment thread include/CLI/App.hpp Outdated
->type_name("RETIRED")
->expected(0, 1)
->default_str("RETIRED");
Validator cv{[opt2](std::string &) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why is this object called cv? Could you find a more epressive name?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

custom validator, I will rename it

Comment thread include/CLI/App.hpp Resolved
Comment thread include/CLI/App.hpp Resolved
Comment thread include/CLI/App.hpp
}

/// Helper function to mark an option as deprecated
inline void deprecate_option(App &app, const std::string &option_name, const std::string &replacement = "") {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

My IDE complains that this function is never used. Is my IDE wrong? Manually, I also can't find usages and wonder how you get 100% coverage.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I thought I was using it one of the tests but I will double check that and make sure

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks!

Comment thread include/CLI/App.hpp Outdated
/// Helper function to mark an option as retired
inline void retire_option(App *app, Option *opt) {
App temp;
auto ropt = temp.add_option(opt->get_name(false, true))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why do you need ropt in addition to opt? Consider a more descriptive name for this object

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We need to create a temporary psuedo copy of the option before destroying the original, and then copying the copy with the critical info. I will rename it something more descriptive though.

phlptp and others added 3 commits December 3, 2019 11:56
Co-Authored-By: Christoph Bachhuber <cbachhuber89@gmail.com>

@cbachhuber cbachhuber left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good, thanks! 👍

@henryiii

henryiii commented Dec 4, 2019

Copy link
Copy Markdown
Collaborator

Looks good to me, are you ready to merge?

@phlptp

phlptp commented Dec 4, 2019

Copy link
Copy Markdown
Collaborator Author

I think it is ready.

@henryiii
henryiii merged commit fc0f82a into CLIUtils:master Dec 5, 2019
@henryiii
henryiii deleted the deprecated_retired_options branch December 5, 2019 02:16
@henryiii henryiii added this to the v1.9 milestone Dec 31, 2019
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.

Feature request: mark a flag as deprecated or retired

3 participants