Skip to content

Commit 70ad448

Browse files
Rename Config.arraySep to valueSep (#184)
1 parent af653fd commit 70ad448

File tree

9 files changed

+19
-17
lines changed

9 files changed

+19
-17
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
* `Config.addHelp` is renamed to `Config.addHelpArgument`.
3131

32+
* `Config.arraySep` is renamed to `Config.valueSep`.
33+
3234
* `Style.namedArgumentName` is renamed to `Style.argumentName`.
3335

3436
* Underlying type of `ansiStylingArgument` argument is changed. It can now be directly cast to boolean instead comparing against `Config.StylingMode`.

docs/code_snippets/config_arraySep.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ T t1;
99
assert(CLI!T.parseArgs(t1, ["-a","1:2:3","-a","4","5"]));
1010
assert(t1 == T(["1:2:3","4","5"]));
1111

12-
enum Config cfg = { arraySep: ':' };
12+
enum Config cfg = { valueSep: ':' };
1313

1414
T t2;
1515
assert(CLI!(cfg, T).parseArgs(t2, ["-a","1:2:3","-a","4","5"]));

docs/code_snippets/types_array_comma.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ struct T
55
int[] a;
66
}
77

8-
enum Config cfg = { arraySep: ',' };
8+
enum Config cfg = { valueSep: ',' };
99

1010
T t;
1111
assert(CLI!(cfg, T).parseArgs(t, ["-a=1,2,3","-a","4,5"]));

docs/code_snippets/types_assoc_array_comma.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ struct T
55
int[string] a;
66
}
77

8-
enum Config cfg = { arraySep: ',' };
8+
enum Config cfg = { valueSep: ',' };
99

1010
T t;
1111
assert(CLI!(cfg, T).parseArgs(t, ["-a=foo=3,boo=7","-a","bar=4,baz=9"]));

docs/topics/Supported-types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ The difference can be easily shown in the following example:
4646

4747
<code-block src="code_snippets/types_array.d" lang="c++"/>
4848

49-
Alternatively one can set [`Config.arraySep`](Config.md#arraySep) to allow multiple elements in one command line entry:
49+
Alternatively one can set [`Config.valueSep`](Config.md#valueSep) to allow multiple elements in one command line entry:
5050

5151
<code-block src="code_snippets/types_array_comma.d" lang="c++"/>
5252

@@ -57,7 +57,7 @@ format of the value is `key=value` (equal sign can be customized with [`Config.a
5757

5858
<code-block src="code_snippets/types_assoc_array.d" lang="c++"/>
5959

60-
Alternatively one can set [`Config.arraySep`](Config.md#arraySep) to allow multiple elements in one command line entry:
60+
Alternatively one can set [`Config.valueSep`](Config.md#valueSep) to allow multiple elements in one command line entry:
6161

6262
<code-block src="code_snippets/types_assoc_array_comma.d" lang="c++"/>
6363

docs/topics/reference/Config.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ Example:
1313

1414
<code-block src="code_snippets/config_assignChar.d" lang="c++"/>
1515

16-
## Array separator {id="arraySep"}
16+
## Value separator {id="valueSep"}
1717

18-
When `Config.arraySep` is set to `char.init`, values to array and associative-array receivers are treated as an individual
19-
value. That is, only one argument is appended/inserted per appearance of the argument. If `arraySep` is set to something
18+
When `Config.valueSep` is set to `char.init`, values to array and associative-array receivers are treated as an individual
19+
value. That is, only one argument is appended/inserted per appearance of the argument. If `valueSep` is set to something
2020
else, then each value is first split by the separator, and the individual pieces are treated as values to the same
2121
argument.
2222

source/argparse/config.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ struct Config
1414
/**
1515
When set to char.init, parameters to array and associative array receivers are
1616
treated as an individual argument. That is, only one argument is appended or
17-
inserted per appearance of the option switch. If `arraySep` is set to
17+
inserted per appearance of the option switch. If `valueSep` is set to
1818
something else, then each parameter is first split by the separator, and the
1919
individual pieces are treated as arguments to the same option.
2020
2121
Defaults to char.init
2222
*/
23-
char arraySep = char.init;
23+
char valueSep = char.init;
2424

2525
/**
2626
The prefix for argument name.

source/argparse/internal/valueparser.d

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,21 +490,21 @@ unittest
490490

491491
private void splitValues(ref RawParam param)
492492
{
493-
if(param.config.arraySep == char.init)
493+
if(param.config.valueSep == char.init)
494494
return;
495495

496496
import std.array : array, split;
497497
import std.algorithm : map, joiner;
498498

499-
param.value = param.value.map!((string s) => s.split(param.config.arraySep)).joiner.array;
499+
param.value = param.value.map!((string s) => s.split(param.config.valueSep)).joiner.array;
500500
}
501501

502502
unittest
503503
{
504-
alias test = (char arraySep, string[] values)
504+
alias test = (char valueSep, string[] values)
505505
{
506506
Config config;
507-
config.arraySep = arraySep;
507+
config.valueSep = valueSep;
508508

509509
auto param = RawParam(&config, "", values);
510510

source/argparse/package.d

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ unittest
610610

611611
enum cfg = {
612612
Config cfg;
613-
cfg.arraySep = ',';
613+
cfg.valueSep = ',';
614614
return cfg;
615615
}();
616616

@@ -636,7 +636,7 @@ unittest
636636

637637
enum cfg = {
638638
Config cfg;
639-
cfg.arraySep = ',';
639+
cfg.valueSep = ',';
640640
return cfg;
641641
}();
642642

@@ -686,7 +686,7 @@ unittest
686686

687687
enum cfg = {
688688
Config cfg;
689-
cfg.arraySep = ',';
689+
cfg.valueSep = ',';
690690
return cfg;
691691
}();
692692

0 commit comments

Comments
 (0)