Skip to content

Commit

Permalink
Rename Config.addHelp to addHelpArgument
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-zherikov committed Jul 11, 2024
1 parent f9b5769 commit d3823a7
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,7 @@ Default is `false`.

### Adding help generation

`Config.addHelp` – when it is set to `true`, then `-h` and `--help` arguments are added to the parser. In case if the
`Config.addHelpArgument` – when it is set to `true`, then `-h` and `--help` arguments are added to the parser. In case if the
command line has one of these arguments, then the corresponding help text is printed and the parsing will be stopped.
If `CLI!(...).parseArgs(alias newMain)` or `CLI!(...).main(alias newMain)` is used, then provided `newMain` function will
not be called.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ T t1;
CLI!T.parseArgs(t1, ["-a", "A", "-h", "-b", "B"]);
assert(t1 == T("A"));

enum Config cfg = { addHelp: false };
enum Config cfg = { addHelpArgument: false };

T t2;
string[] unrecognizedArgs;
Expand Down
6 changes: 3 additions & 3 deletions docs/topics/reference/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ Example:

<code-block src="code_snippets/config_bundling.d" lang="c++"/>

## Adding help generation {id="addHelp"}
## Adding help generation {id="addHelpArgument"}

`Config.addHelp` can be used to add (if `true`) or not (if `false`) `-h`/`--help` argument.
`Config.addHelpArgument` can be used to add (if `true`) or not (if `false`) `-h`/`--help` argument.
In case if the command line has `-h` or `--help`, then the corresponding help text is printed and the parsing is stopped.
If `CLI!(...).parseArgs(alias newMain)` or `CLI!(...).main(alias newMain)` is used, then provided `newMain` function will
not be called.
Expand All @@ -81,7 +81,7 @@ Default is `true`.

Example:

<code-block src="code_snippets/config_addHelp.d" lang="c++"/>
<code-block src="code_snippets/config_addHelpArgument.d" lang="c++"/>

Help text from the first part of the example code above:

Expand Down
4 changes: 2 additions & 2 deletions source/argparse/config.d
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ struct Config
bool bundling = false;

/**
Add a -h/--help option to the parser.
Add a -h/--help argument to the parser.
Defaults to true.
*/
bool addHelp = true;
bool addHelpArgument = true;

/**
Styling.
Expand Down
2 changes: 1 addition & 1 deletion source/argparse/internal/command.d
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ private template TypeTraits(Config config, TYPE)
private enum positional(ArgumentInfo info) = info.positional;
private enum comparePosition(ArgumentInfo info1, ArgumentInfo info2) = info1.position.get - info2.position.get;

static if(config.addHelp)
static if(config.addHelpArgument)
{
private enum helpUDA = HelpArgumentUDA(HelpArgumentUDA.init.info.finalize!bool(config, null));
enum argumentUDAs = AliasSeq!(staticMap!(getArgumentUDA, iterateArguments!TYPE), helpUDA);
Expand Down
4 changes: 2 additions & 2 deletions source/argparse/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ unittest

enum config = {
Config config;
config.addHelp = false;
config.addHelpArgument = false;
return config;
}();

Expand All @@ -67,7 +67,7 @@ unittest

enum config = {
Config config;
config.addHelp = false;
config.addHelpArgument = false;
return config;
}();

Expand Down

0 comments on commit d3823a7

Please sign in to comment.