Skip to content

Commit f7befac

Browse files
authored
(#644) Specified settings for the argument vector (#1301)
1 parent cec5fb4 commit f7befac

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

docs/input/cli/settings.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Title: Specifying Settings
22
Order: 5
33
Description: "How to define command line argument settings for your *Spectre.Console.Cli* Commands"
4-
Reference:
4+
Reference:
55
- T:Spectre.Console.Cli.CommandSettings
66
- T:Spectre.Console.Cli.CommandArgumentAttribute
77
- T:Spectre.Console.Cli.CommandOptionAttribute
@@ -86,7 +86,9 @@ public int Count { get; set; }
8686

8787
## Arrays
8888

89-
`CommandArgument` can be defined as arrays and any additional parameters will be included in the value. For example
89+
### Argument Vector
90+
91+
One (exactly one) `CommandArgument` can be defined as an array, and any additional parameters will be included in the value. For example:
9092

9193
```csharp
9294
[CommandArgument(0, "[name]")]
@@ -95,6 +97,19 @@ public string[] Name { get; set; }
9597

9698
Would allow the user to run `app.exe Dwayne Elizondo "Mountain Dew" Herbert Camacho`. The settings passed to the command would have a 5 element array consisting of Dwayne, Elizondo, Mountain Dew, Herbert and Camacho.
9799

100+
A command can have only one argument vector, and it needs to be the last argument. (I.e. there can be no `CommandArgument` whose position is higher than that of the argument vector.)
101+
102+
### Option Arrays
103+
104+
A `CommandOption` can be defined as an array like the following:
105+
106+
```csharp
107+
[CommandOption("-n|--name <VALUES>")]
108+
public string[] Names { get; set; },
109+
```
110+
111+
This would allow the user to run `app.exe --name Dwayne --name Elizondo --name "Mountain Dew" --name Herbert --name Camacho` and would result in a 5 element array consisting of Dwayne, Elizondo, Mountain Dew, Herbert and Camacho.
112+
98113
## Constructors
99114

100115
`Spectre.Console.Cli` supports constructor initialization and init only initialization. For constructor initialization, the parameter name of the constructor must match the name of the property name of the settings class. Order does not matter.

0 commit comments

Comments
 (0)