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

Add a 'required' feature #33

Merged
merged 2 commits into from
Aug 6, 2019
Merged

Conversation

wtdcode
Copy link
Contributor

@wtdcode wtdcode commented Aug 6, 2019

If an argument is required and it

  • doesn't have a default value and is not set. => exception
  • doesn't have a default value and is set without any value. => exception
  • doesn't have a default value and is set with some value. => use the value provided.
  • has a default value and is not set. => use the default value.
  • has a default value and is set without any value. => exception
  • has a default value and is set with some value. => use the value provided.

If an argument is not required, nothing changes.

I will add some tests later.

Also see #27.

@@ -179,7 +194,11 @@ class Argument {
friend std::ostream& operator<<(std::ostream& stream, const Argument& argument) {
std::stringstream nameStream;
std::copy(std::begin(argument.mNames), std::end(argument.mNames), std::ostream_iterator<std::string>(nameStream, " "));
return stream << nameStream.str() << "\t" << argument.mHelp << "\n";
stream << nameStream.str() << "\t" << argument.mHelp;
if (argument.mIsRequired)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: I change the format of required arguments.

@p-ranav p-ranav merged commit e8dcc7e into p-ranav:master Aug 6, 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.

2 participants