Skip to content

Commit 5c17b2a

Browse files
committed
Added new Input fns: "acceptOnlyFromAmong", "arity" and "allowMultipleArgumentsPerToken"
1 parent 93af289 commit 5c17b2a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/FSharp.SystemCommandLine/Inputs.fs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ module Input =
190190
|> editOption (fun o -> o.Validators.Add(validator))
191191
|> editArgument (fun a -> a.Validators.Add(validator))
192192

193+
let acceptOnlyFromAmong (acceptedValues: string seq) (input: ActionInput<'T>) =
194+
input
195+
|> editOption (fun o -> o.AcceptOnlyFromAmong(acceptedValues |> Seq.toArray) |> ignore)
196+
|> editArgument (fun a -> a.AcceptOnlyFromAmong(acceptedValues |> Seq.toArray) |> ignore)
197+
193198
/// Parses the input using a custom parser function.
194199
let customParser (parser: Parsing.ArgumentResult -> 'T) (input: ActionInput<'T>) =
195200
input
@@ -208,6 +213,17 @@ module Input =
208213
Unchecked.defaultof<'T>
209214
)
210215

216+
/// Sets the arity of an option or argument.
217+
let arity (arity: ArgumentArity) (input: ActionInput<'T>) =
218+
input
219+
|> editOption (fun o -> o.Arity <- arity)
220+
|> editArgument (fun a -> a.Arity <- arity)
221+
222+
/// Sets a value that indicates whether multiple arguments are allowed for each option identifier token. (Defaults to 'false'.)
223+
let allowMultipleArgumentsPerToken (input: ActionInput<'T>) =
224+
input
225+
|> editOption (fun a -> a.AllowMultipleArgumentsPerToken <- true)
226+
211227
/// Converts an `Option<'T>` to an `ActionInput<'T>` for usage with the command builders.
212228
let ofOption (o: Option<'T>) =
213229
ActionInput.OfOption<'T> o

0 commit comments

Comments
 (0)