From 2c024401cc828cb0b61bec11c67bf277bfd6e353 Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Sun, 6 Jan 2019 10:46:12 +0100 Subject: [PATCH] Minor touch up after #186 --- .editorconfig | 9 +++++++++ CHANGELOG.md | 6 ++++-- README.md | 3 ++- extern/json | 2 +- include/CLI/App.hpp | 10 +++++----- tests/CMakeLists.txt | 2 +- 6 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..35463ab --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +insert_final_newline = true +end_of_line = lf +trim_trailing_whitespace = true + diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a911fa..896466d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,9 @@ -## Version 1.7.0: Parse breakup +## Version 1.7.0: Parse breakup (in progress) 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. -Passing the same subcommand multiple times is better supported. A new feature, `ignore_underscore` was added, as well, to ignore underscores in names. +Passing the same subcommand multiple times is better supported. A few new features were added as well. +* Added `parse(string)` to split up and parse a command-line style string directly. [#186] * Added `ignore_underscore` and related functions, to ignore underscores when matching names. [#185] * 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] * 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, ` [#179]: https://github.com/CLIUtils/CLI11/pull/179 [#183]: https://github.com/CLIUtils/CLI11/pull/183 [#185]: https://github.com/CLIUtils/CLI11/pull/185 +[#186]: https://github.com/CLIUtils/CLI11/pull/186 ## Version 1.6.2: Help-all diff --git a/README.md b/README.md index f9683e7..01f0f19 100644 --- a/README.md +++ b/README.md @@ -371,7 +371,8 @@ The App class was designed allow toolkits to subclass it, to provide preset defa but before run behavior, while still giving the user freedom to `callback` on the main app. -The most important parse function is `parse(std::vector)`, 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. +The most important parse function is `parse(std::vector)`, 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 +including the program name in the string. 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. diff --git a/extern/json b/extern/json index f1768a5..db53bda 160000 --- a/extern/json +++ b/extern/json @@ -1 +1 @@ -Subproject commit f1768a540a7b7c5cc30cdcd6be9e9ef91083719b +Subproject commit db53bdac1926d1baebcb459b685dcd2e4608c355 diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index 237530a..d773e01 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -1154,7 +1154,7 @@ class App { } } - /// Parses the command line - throws errors + /// Parses the command line - throws errors. /// This must be called after the options are in but before the rest of the program. void parse(int argc, const char *const *argv) { // If the name is not set, read from command line @@ -1167,13 +1167,13 @@ class App { parse(args); } - /// parse a single string as if it contained command line arguments - /// this function splits the string into arguments then calls parse(std::vector &) + /// Parse a single string as if it contained command line arguments. + /// This function splits the string into arguments then calls parse(std::vector &) /// the function takes an optional boolean argument specifying if the programName is included in the string to /// process - void parse(std::string commandline, bool ProgramNameIncluded = false) { + void parse(std::string commandline, bool program_name_included = false) { detail::trim(commandline); - if(ProgramNameIncluded) { + if(program_name_included) { // try to determine the programName auto esp = commandline.find_first_of(' ', 1); while(!ExistingFile(commandline.substr(0, esp)).empty()) { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ffbdf43..1d70a4d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -33,7 +33,7 @@ set(CLI11_TESTS NewParseTest OptionalTest DeprecatedTest - StringParseTest + StringParseTest ) if(WIN32) -- libgit2 0.21.4