You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/input/cli/settings.md
+17-2Lines changed: 17 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
Title: Specifying Settings
2
2
Order: 5
3
3
Description: "How to define command line argument settings for your *Spectre.Console.Cli* Commands"
4
-
Reference:
4
+
Reference:
5
5
- T:Spectre.Console.Cli.CommandSettings
6
6
- T:Spectre.Console.Cli.CommandArgumentAttribute
7
7
- T:Spectre.Console.Cli.CommandOptionAttribute
@@ -86,7 +86,9 @@ public int Count { get; set; }
86
86
87
87
## Arrays
88
88
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:
90
92
91
93
```csharp
92
94
[CommandArgument(0, "[name]")]
@@ -95,6 +97,19 @@ public string[] Name { get; set; }
95
97
96
98
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.
97
99
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
+
publicstring[] 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
+
98
113
## Constructors
99
114
100
115
`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