Commit 2c024401cc828cb0b61bec11c67bf277bfd6e353
1 parent
30c2e327
Minor touch up after #186
Showing
6 changed files
with
22 additions
and
10 deletions
.editorconfig
0 → 100644
CHANGELOG.md
| 1 | -## Version 1.7.0: Parse breakup | |
| 1 | +## Version 1.7.0: Parse breakup (in progress) | |
| 2 | 2 | |
| 3 | 3 | The parsing procedure now maps much more sensibly to complex, nested subcommand structures. Each phase of the parsing happens on all subcommands before moving on with the next phase of the parse. This allows several features, like required environment variables, to work properly even through subcommand boundaries. |
| 4 | -Passing the same subcommand multiple times is better supported. A new feature, `ignore_underscore` was added, as well, to ignore underscores in names. | |
| 4 | +Passing the same subcommand multiple times is better supported. A few new features were added as well. | |
| 5 | 5 | |
| 6 | +* Added `parse(string)` to split up and parse a command-line style string directly. [#186] | |
| 6 | 7 | * Added `ignore_underscore` and related functions, to ignore underscores when matching names. [#185] |
| 7 | 8 | * Subcommands now track how many times they were parsed in a parsing process. `count()` with no arguments will return the number of times a subcommand was encountered. [#179] |
| 8 | 9 | * Parsing is now done in phases: `shortcurcuits`, `ini`, `env`, `callbacks`, and `requirements`; all subcommands complete a phase before moving on. [#179] |
| ... | ... | @@ -13,6 +14,7 @@ Passing the same subcommand multiple times is better supported. A new feature, ` |
| 13 | 14 | [#179]: https://github.com/CLIUtils/CLI11/pull/179 |
| 14 | 15 | [#183]: https://github.com/CLIUtils/CLI11/pull/183 |
| 15 | 16 | [#185]: https://github.com/CLIUtils/CLI11/pull/185 |
| 17 | +[#186]: https://github.com/CLIUtils/CLI11/pull/186 | |
| 16 | 18 | |
| 17 | 19 | ## Version 1.6.2: Help-all |
| 18 | 20 | ... | ... |
README.md
| ... | ... | @@ -371,7 +371,8 @@ The App class was designed allow toolkits to subclass it, to provide preset defa |
| 371 | 371 | but before run behavior, while |
| 372 | 372 | still giving the user freedom to `callback` on the main app. |
| 373 | 373 | |
| 374 | -The most important parse function is `parse(std::vector<std::string>)`, which takes a reversed list of arguments (so that `pop_back` processes the args in the correct order). `get_help_ptr` and `get_config_ptr` give you access to the help/config option pointers. The standard `parse` manually sets the name from the first argument, so it should not be in this vector. | |
| 374 | +The most important parse function is `parse(std::vector<std::string>)`, which takes a reversed list of arguments (so that `pop_back` processes the args in the correct order). `get_help_ptr` and `get_config_ptr` give you access to the help/config option pointers. The standard `parse` manually sets the name from the first argument, so it should not be in this vector. You can also use `parse(string, bool)` to split up and parse a string; the optional bool should be set to true if you are | |
| 375 | +including the program name in the string. | |
| 375 | 376 | |
| 376 | 377 | Also, in a related note, the `App` you get a pointer to is stored in the parent `App` in a `unique_ptr`s (like `Option`s) and are deleted when the main `App` goes out of scope. |
| 377 | 378 | ... | ... |
include/CLI/App.hpp
| ... | ... | @@ -1154,7 +1154,7 @@ class App { |
| 1154 | 1154 | } |
| 1155 | 1155 | } |
| 1156 | 1156 | |
| 1157 | - /// Parses the command line - throws errors | |
| 1157 | + /// Parses the command line - throws errors. | |
| 1158 | 1158 | /// This must be called after the options are in but before the rest of the program. |
| 1159 | 1159 | void parse(int argc, const char *const *argv) { |
| 1160 | 1160 | // If the name is not set, read from command line |
| ... | ... | @@ -1167,13 +1167,13 @@ class App { |
| 1167 | 1167 | parse(args); |
| 1168 | 1168 | } |
| 1169 | 1169 | |
| 1170 | - /// parse a single string as if it contained command line arguments | |
| 1171 | - /// this function splits the string into arguments then calls parse(std::vector<std::string> &) | |
| 1170 | + /// Parse a single string as if it contained command line arguments. | |
| 1171 | + /// This function splits the string into arguments then calls parse(std::vector<std::string> &) | |
| 1172 | 1172 | /// the function takes an optional boolean argument specifying if the programName is included in the string to |
| 1173 | 1173 | /// process |
| 1174 | - void parse(std::string commandline, bool ProgramNameIncluded = false) { | |
| 1174 | + void parse(std::string commandline, bool program_name_included = false) { | |
| 1175 | 1175 | detail::trim(commandline); |
| 1176 | - if(ProgramNameIncluded) { | |
| 1176 | + if(program_name_included) { | |
| 1177 | 1177 | // try to determine the programName |
| 1178 | 1178 | auto esp = commandline.find_first_of(' ', 1); |
| 1179 | 1179 | while(!ExistingFile(commandline.substr(0, esp)).empty()) { | ... | ... |