diff --git a/README.md b/README.md index 94a6667..ba1c616 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ * `Config.addHelp` is renamed to `Config.addHelpArgument`. + * `Config.arraySep` is renamed to `Config.valueSep`. + * `Style.namedArgumentName` is renamed to `Style.argumentName`. * Underlying type of `ansiStylingArgument` argument is changed. It can now be directly cast to boolean instead comparing against `Config.StylingMode`. diff --git a/docs/code_snippets/config_arraySep.d b/docs/code_snippets/config_arraySep.d index 71e03dc..df5417a 100644 --- a/docs/code_snippets/config_arraySep.d +++ b/docs/code_snippets/config_arraySep.d @@ -9,7 +9,7 @@ T t1; assert(CLI!T.parseArgs(t1, ["-a","1:2:3","-a","4","5"])); assert(t1 == T(["1:2:3","4","5"])); -enum Config cfg = { arraySep: ':' }; +enum Config cfg = { valueSep: ':' }; T t2; assert(CLI!(cfg, T).parseArgs(t2, ["-a","1:2:3","-a","4","5"])); diff --git a/docs/code_snippets/types_array_comma.d b/docs/code_snippets/types_array_comma.d index c1bf22e..f64952b 100644 --- a/docs/code_snippets/types_array_comma.d +++ b/docs/code_snippets/types_array_comma.d @@ -5,7 +5,7 @@ struct T int[] a; } -enum Config cfg = { arraySep: ',' }; +enum Config cfg = { valueSep: ',' }; T t; assert(CLI!(cfg, T).parseArgs(t, ["-a=1,2,3","-a","4,5"])); diff --git a/docs/code_snippets/types_assoc_array_comma.d b/docs/code_snippets/types_assoc_array_comma.d index d597ddf..516abf4 100644 --- a/docs/code_snippets/types_assoc_array_comma.d +++ b/docs/code_snippets/types_assoc_array_comma.d @@ -5,7 +5,7 @@ struct T int[string] a; } -enum Config cfg = { arraySep: ',' }; +enum Config cfg = { valueSep: ',' }; T t; assert(CLI!(cfg, T).parseArgs(t, ["-a=foo=3,boo=7","-a","bar=4,baz=9"])); diff --git a/docs/topics/Supported-types.md b/docs/topics/Supported-types.md index 9f4fc4c..88487ab 100644 --- a/docs/topics/Supported-types.md +++ b/docs/topics/Supported-types.md @@ -46,7 +46,7 @@ The difference can be easily shown in the following example: -Alternatively one can set [`Config.arraySep`](Config.md#arraySep) to allow multiple elements in one command line entry: +Alternatively one can set [`Config.valueSep`](Config.md#valueSep) to allow multiple elements in one command line entry: @@ -57,7 +57,7 @@ format of the value is `key=value` (equal sign can be customized with [`Config.a -Alternatively one can set [`Config.arraySep`](Config.md#arraySep) to allow multiple elements in one command line entry: +Alternatively one can set [`Config.valueSep`](Config.md#valueSep) to allow multiple elements in one command line entry: diff --git a/docs/topics/reference/Config.md b/docs/topics/reference/Config.md index 57ecf17..c4d8a42 100644 --- a/docs/topics/reference/Config.md +++ b/docs/topics/reference/Config.md @@ -13,10 +13,10 @@ Example: -## Array separator {id="arraySep"} +## Value separator {id="valueSep"} -When `Config.arraySep` is set to `char.init`, values to array and associative-array receivers are treated as an individual -value. That is, only one argument is appended/inserted per appearance of the argument. If `arraySep` is set to something +When `Config.valueSep` is set to `char.init`, values to array and associative-array receivers are treated as an individual +value. That is, only one argument is appended/inserted per appearance of the argument. If `valueSep` is set to something else, then each value is first split by the separator, and the individual pieces are treated as values to the same argument. diff --git a/source/argparse/config.d b/source/argparse/config.d index e2423e9..d8fe2b4 100644 --- a/source/argparse/config.d +++ b/source/argparse/config.d @@ -14,13 +14,13 @@ struct Config /** When set to char.init, parameters to array and associative array receivers are treated as an individual argument. That is, only one argument is appended or - inserted per appearance of the option switch. If `arraySep` is set to + inserted per appearance of the option switch. If `valueSep` is set to something else, then each parameter is first split by the separator, and the individual pieces are treated as arguments to the same option. Defaults to char.init */ - char arraySep = char.init; + char valueSep = char.init; /** The prefix for argument name. diff --git a/source/argparse/internal/valueparser.d b/source/argparse/internal/valueparser.d index a40d4b3..246ac37 100644 --- a/source/argparse/internal/valueparser.d +++ b/source/argparse/internal/valueparser.d @@ -490,21 +490,21 @@ unittest private void splitValues(ref RawParam param) { - if(param.config.arraySep == char.init) + if(param.config.valueSep == char.init) return; import std.array : array, split; import std.algorithm : map, joiner; - param.value = param.value.map!((string s) => s.split(param.config.arraySep)).joiner.array; + param.value = param.value.map!((string s) => s.split(param.config.valueSep)).joiner.array; } unittest { - alias test = (char arraySep, string[] values) + alias test = (char valueSep, string[] values) { Config config; - config.arraySep = arraySep; + config.valueSep = valueSep; auto param = RawParam(&config, "", values); diff --git a/source/argparse/package.d b/source/argparse/package.d index df957dd..12aaf36 100644 --- a/source/argparse/package.d +++ b/source/argparse/package.d @@ -610,7 +610,7 @@ unittest enum cfg = { Config cfg; - cfg.arraySep = ','; + cfg.valueSep = ','; return cfg; }(); @@ -636,7 +636,7 @@ unittest enum cfg = { Config cfg; - cfg.arraySep = ','; + cfg.valueSep = ','; return cfg; }(); @@ -686,7 +686,7 @@ unittest enum cfg = { Config cfg; - cfg.arraySep = ','; + cfg.valueSep = ','; return cfg; }();