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

Postpone conversions #1

Merged
merged 11 commits into from Jul 25, 2020
Merged

Postpone conversions #1

merged 11 commits into from Jul 25, 2020

Conversation

ggabriel96
Copy link
Owner

@ggabriel96 ggabriel96 commented Jul 25, 2020

General description

This is a step back from what we currently have so we can:

  1. avoid using std::any
  2. only ask the user once for the desired type
  3. prepare for The return of templated Arg? #5
  4. prepare to support different actions

Technical details

  • changes in types:
    • Arg now only has name, help, and required and becomes an aggregate
    • removed ArgInfo
    • ArgValue stores a std::string instead of std::any
    • gave up on operator T (see discussion)
    • new member functions get_if_else, value_or, and as in ArgMap
    • SplitArg becomes ParsedOption
  • adapted converters, replacing std::optional<std::string> with std::string
  • changes in Program:
    • member function add break into pos, opt, and flag (currently lacking needed checks)
    • removed add_choice_checking_to_conversion
    • directly storing Arg
    • separate containers for flags, options, and positional arguments
    • with separate containers, is_flag only needs to check if the flags container has the given name
    • convert_args becomes assign_args
    • only assign parsed arguments (default values will come later)
    • now handling too many dashes
    • now detecting user-provided values for flags during parsing
  • other changes in src/opzioni.cpp:
  • exception ArgumentNotFound was not being used, so got replaced by MissingRequiredArgument; new exception TooManyDashes
  • temporarily removed tests in src/types.test.cpp
  • commited variant.cpp by mistake, but now it's saved for later 🤷‍♂️ (will use it as a base for the std::variant implementation mentioned earlier)

@ggabriel96 ggabriel96 added the step-back Remove or hold a feature to prepare the code for a better future implementation label Jul 25, 2020
@ggabriel96 ggabriel96 self-assigned this Jul 25, 2020
@ggabriel96 ggabriel96 added this to In progress in Roadmap to 1.0 via automation Jul 25, 2020
@ggabriel96 ggabriel96 merged commit b323b0c into main Jul 25, 2020
Roadmap to 1.0 automation moved this from In progress to Done Jul 25, 2020
@ggabriel96 ggabriel96 deleted the postpone-conversions branch July 25, 2020 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
step-back Remove or hold a feature to prepare the code for a better future implementation
Projects
Development

Successfully merging this pull request may close these issues.

Refactor split_arg Reconsider parsing and assignment of flags Parsing allows multiple dashes
1 participant