Skip to content

Conversation

@phlptp
Copy link
Collaborator

@phlptp phlptp commented Apr 9, 2020

Add a version operation, similar to config and help, to print out the version and exit. Supports adding the version via a string or callback.

We had been doing this in our application and it might seem to be something that is pretty common to want in applications

@codecov
Copy link

codecov bot commented Apr 9, 2020

Codecov Report

Merging #452 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #452   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           12        12           
  Lines         3687      3724   +37     
=========================================
+ Hits          3687      3724   +37     
Impacted Files Coverage Δ
include/CLI/StringTools.hpp 100.00% <ø> (ø)
include/CLI/TypeTools.hpp 100.00% <ø> (ø)
include/CLI/App.hpp 100.00% <100.00%> (ø)
include/CLI/Error.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 fff3350...486fcbf. Read the comment docs.

@phlptp phlptp changed the title [WIP] Version add Version add Apr 9, 2020
}
/// Set the version as a string
App *version(const std::string &versionString) {
set_version_flag("-v,--version", versionString);

Choose a reason for hiding this comment

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

-v is commonly also used for verbose by programs (including cp, rm, wget, curl, mv).

Choose a reason for hiding this comment

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

So is -V basically it's a guess which one will be equivalent to --version and which to --verbose. Each default is equally good/bad.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok, I removed the "-v" from the default since it seems that could mean any number of different things from common applications.

@phlptp
Copy link
Collaborator Author

phlptp commented Apr 18, 2020

closes #436

@phlptp phlptp linked an issue Apr 26, 2020 that may be closed by this pull request
@henryiii
Copy link
Collaborator

henryiii commented May 21, 2020

I am not really sure we need to have the version shortcut. It only adds the "--version" for you - which I was going to consider suggesting as an argument, but then that's exactly what set_version_flag is. There's also some ambiguity in whether it is setting the version or accessing the version (which is not needed, but it's not completely clear). Thoughts?

@phlptp
Copy link
Collaborator Author

phlptp commented May 21, 2020

I am fine removing it, hadn't thought about the ambiguity on whether it would be accessing the version.

@phlptp
Copy link
Collaborator Author

phlptp commented May 21, 2020

Do we want to keep the std::string version() const operation?

@henryiii
Copy link
Collaborator

No (I'd missed that, actually), but that's what I would expect "version()" to do; the dual use might be also a bit confusing.

@phlptp
Copy link
Collaborator Author

phlptp commented May 21, 2020

removed all version methods

@henryiii
Copy link
Collaborator

henryiii commented May 21, 2020

I'm sorry, I meant "Yes, we could keep it" - somehow I stared with No then (I think) explained why we should keep it. I was just saying that version() returning a string and version(string) could possibly be confusing, so it was another reason that it might be nice to remove version(string).

@phlptp
Copy link
Collaborator Author

phlptp commented May 21, 2020

ok, I will that one back in :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add a version callback similar to help

4 participants