Skip to content

Commit c463b93

Browse files
Puppy4Csbrannen
authored andcommitted
Update Javadoc for SimpleCommandLinePropertySource
For ComandLineArgs, supplying the same option multiple times with different values is valid, and the values will be stored in a List. This commit also updates the Javadoc for SimpleCommandLineArgsParser. See gh-34282 Signed-off-by: puppy4c <[email protected]>
1 parent 4783c32 commit c463b93

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

spring-core/src/main/java/org/springframework/core/env/SimpleCommandLineArgsParser.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
* <p>That is, options must be prefixed with "{@code --}" and may or may not
2929
* specify a value. If a value is specified, the name and value must be separated
3030
* <em>without spaces</em> by an equals sign ("="). The value may optionally be
31-
* an empty string.
31+
* an empty string. if the option is present and has multiple values (e. g. "--foo=bar --foo=baz"),
32+
* the values are parsed as a collection.
3233
*
3334
* <h4>Valid examples of option arguments</h4>
3435
* <pre class="code">
@@ -37,14 +38,14 @@
3738
* --foo=""
3839
* --foo=bar
3940
* --foo="bar then baz"
40-
* --foo=bar,baz,biz</pre>
41+
* --foo=bar,baz,biz
42+
* --foo=bar --foo=baz --foo=biz</pre>
4143
*
4244
* <h4>Invalid examples of option arguments</h4>
4345
* <pre class="code">
4446
* -foo
4547
* --foo bar
46-
* --foo = bar
47-
* --foo=bar --foo=baz --foo=biz</pre>
48+
* --foo = bar</pre>
4849
*
4950
* <h3>End of option arguments</h3>
5051
* <p>This parser supports the POSIX "end of options" delimiter, meaning that any

spring-core/src/main/java/org/springframework/core/env/SimpleCommandLinePropertySource.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
* <p>That is, options must be prefixed with "{@code --}" and may or may not
4141
* specify a value. If a value is specified, the name and value must be separated
4242
* <em>without spaces</em> by an equals sign ("="). The value may optionally be
43-
* an empty string.
43+
* an empty string. if the option is present and has multiple values (e. g. "--foo=bar --foo=baz"),
44+
* the values are parsed as a collection.
4445
*
4546
* <h4>Valid examples of option arguments</h4>
4647
* <pre class="code">
@@ -49,14 +50,14 @@
4950
* --foo=""
5051
* --foo=bar
5152
* --foo="bar then baz"
52-
* --foo=bar,baz,biz</pre>
53+
* --foo=bar,baz,biz
54+
* --foo=bar --foo=baz --foo=biz</pre>
5355
*
5456
* <h4>Invalid examples of option arguments</h4>
5557
* <pre class="code">
5658
* -foo
5759
* --foo bar
58-
* --foo = bar
59-
* --foo=bar --foo=baz --foo=biz</pre>
60+
* --foo = bar</pre>
6061
*
6162
* <h3>End of option arguments</h3>
6263
* <p>The underlying parser supports the POSIX "end of options" delimiter, meaning

0 commit comments

Comments
 (0)