Skip to content

Commit d9ab78c

Browse files
committed
Renamed HandlerInput to ActionInput
1 parent c93173a commit d9ab78c

File tree

3 files changed

+59
-59
lines changed

3 files changed

+59
-59
lines changed

src/FSharp.SystemCommandLine/CommandBuilders.fs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ open System.CommandLine.Parsing
99

1010
let private def<'T> = Unchecked.defaultof<'T>
1111

12-
/// Gets the underlying value of a `HandlerInput` based on its source.
13-
let private parseInput<'V> (handlerInput: HandlerInput) (pr: ParseResult) (cancelToken: CancellationToken) =
12+
/// Gets the underlying value of a `ActionInput` based on its source.
13+
let private parseInput<'V> (handlerInput: ActionInput) (pr: ParseResult) (cancelToken: CancellationToken) =
1414
match handlerInput.Source with
1515
| ParsedOption o -> pr.GetValue<'V>(o :?> Option<'V>)
1616
| ParsedArgument a -> pr.GetValue<'V>(a :?> Argument<'V>)
1717
| Context -> { ParseResult = pr; CancellationToken = cancelToken } |> unbox<'V>
1818

1919
/// Adds global options to a command, ensuring they are recursive.
20-
let private addGlobalOptionsToCommand (globalOptions: HandlerInput list) (cmd: Command) =
20+
let private addGlobalOptionsToCommand (globalOptions: ActionInput list) (cmd: Command) =
2121
for g in globalOptions do
2222
match g.Source with
2323
| ParsedOption o ->
@@ -30,13 +30,13 @@ let private addGlobalOptionsToCommand (globalOptions: HandlerInput list) (cmd: C
3030
type CommandSpec<'Inputs, 'Output> =
3131
{
3232
Description: string
33-
Inputs: HandlerInput list
34-
GlobalInputs: HandlerInput list
33+
Inputs: ActionInput list
34+
GlobalInputs: ActionInput list
3535
Handler: 'Inputs -> 'Output
3636
Aliases: string list
3737
SubCommands: System.CommandLine.Command list
3838
/// Registers extra inputs that can be parsed via the InvocationContext if more than 8 are required.
39-
ExtraInputs: HandlerInput list
39+
ExtraInputs: ActionInput list
4040
}
4141
static member Default =
4242
{
@@ -64,7 +64,7 @@ type BaseCommandBuilder<'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'Output>() =
6464
}
6565

6666
/// Converts up to 8 handler inputs into a tuple of the specified action input type.
67-
let inputsToTuple (pr: ParseResult) (ct: CancellationToken) (inputs: HandlerInput list) =
67+
let inputsToTuple (pr: ParseResult) (ct: CancellationToken) (inputs: ActionInput list) =
6868
match inputs.Length with
6969
| 0 ->
7070
box ()
@@ -140,42 +140,42 @@ type BaseCommandBuilder<'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'Output>() =
140140

141141
/// A tuple of inputs (max. 8) that must exactly match the handler function inputs.
142142
[<CustomOperation("inputs")>]
143-
member this.Inputs (spec: CommandSpec<'T, 'Output>, a: HandlerInput<'A>) =
143+
member this.Inputs (spec: CommandSpec<'T, 'Output>, a: ActionInput<'A>) =
144144
{ newHandler def<'A -> 'Output> spec with Inputs = [ a ] }
145145

146146
/// A tuple of inputs (max. 8) that must exactly match the handler function inputs.
147147
[<CustomOperation("inputs")>]
148-
member this.Inputs (spec: CommandSpec<'T, 'Output>, (a: HandlerInput<'A>, b: HandlerInput<'B>)) =
148+
member this.Inputs (spec: CommandSpec<'T, 'Output>, (a: ActionInput<'A>, b: ActionInput<'B>)) =
149149
{ newHandler def<'A * 'B -> 'Output> spec with Inputs = [ a; b ] }
150150

151151
/// A tuple of inputs (max. 8) that must exactly match the handler function inputs.
152152
[<CustomOperation("inputs")>]
153-
member this.Inputs (spec: CommandSpec<'T, 'Output>, (a: HandlerInput<'A>, b: HandlerInput<'B>, c: HandlerInput<'C>)) =
153+
member this.Inputs (spec: CommandSpec<'T, 'Output>, (a: ActionInput<'A>, b: ActionInput<'B>, c: ActionInput<'C>)) =
154154
{ newHandler def<'A * 'B * 'C -> 'Output> spec with Inputs = [ a; b; c ] }
155155

156156
/// A tuple of inputs (max. 8) that must exactly match the handler function inputs.
157157
[<CustomOperation("inputs")>]
158-
member this.Inputs (spec: CommandSpec<'T, 'Output>, (a: HandlerInput<'A>, b: HandlerInput<'B>, c: HandlerInput<'C>, d: HandlerInput<'D>)) =
158+
member this.Inputs (spec: CommandSpec<'T, 'Output>, (a: ActionInput<'A>, b: ActionInput<'B>, c: ActionInput<'C>, d: ActionInput<'D>)) =
159159
{ newHandler def<'A * 'B * 'C * 'D -> 'Output> spec with Inputs = [ a; b; c; d ] }
160160

161161
/// A tuple of inputs (max. 8) that must exactly match the handler function inputs.
162162
[<CustomOperation("inputs")>]
163-
member this.Inputs (spec: CommandSpec<'T, 'Output>, (a: HandlerInput<'A>, b: HandlerInput<'B>, c: HandlerInput<'C>, d: HandlerInput<'D>, e: HandlerInput<'E>)) =
163+
member this.Inputs (spec: CommandSpec<'T, 'Output>, (a: ActionInput<'A>, b: ActionInput<'B>, c: ActionInput<'C>, d: ActionInput<'D>, e: ActionInput<'E>)) =
164164
{ newHandler def<'A * 'B * 'C * 'D * 'E -> 'Output> spec with Inputs = [ a; b; c; d; e ] }
165165

166166
/// A tuple of inputs (max. 8) that must exactly match the handler function inputs.
167167
[<CustomOperation("inputs")>]
168-
member this.Inputs (spec: CommandSpec<'T, 'Output>, (a: HandlerInput<'A>, b: HandlerInput<'B>, c: HandlerInput<'C>, d: HandlerInput<'D>, e: HandlerInput<'E>, f: HandlerInput<'F>)) =
168+
member this.Inputs (spec: CommandSpec<'T, 'Output>, (a: ActionInput<'A>, b: ActionInput<'B>, c: ActionInput<'C>, d: ActionInput<'D>, e: ActionInput<'E>, f: ActionInput<'F>)) =
169169
{ newHandler def<'A * 'B * 'C * 'D * 'E * 'F -> 'Output> spec with Inputs = [ a; b; c; d; e; f ] }
170170

171171
/// A tuple of inputs (max. 8) that must exactly match the handler function inputs.
172172
[<CustomOperation("inputs")>]
173-
member this.Inputs (spec: CommandSpec<'T, 'Output>, (a: HandlerInput<'A>, b: HandlerInput<'B>, c: HandlerInput<'C>, d: HandlerInput<'D>, e: HandlerInput<'E>, f: HandlerInput<'F>, g: HandlerInput<'G>)) =
173+
member this.Inputs (spec: CommandSpec<'T, 'Output>, (a: ActionInput<'A>, b: ActionInput<'B>, c: ActionInput<'C>, d: ActionInput<'D>, e: ActionInput<'E>, f: ActionInput<'F>, g: ActionInput<'G>)) =
174174
{ newHandler def<'A * 'B * 'C * 'D * 'E * 'F * 'G -> 'Output> spec with Inputs = [ a; b; c; d; e; f; g ] }
175175

176176
/// A tuple of inputs (max. 8) that must exactly match the handler function inputs.
177177
[<CustomOperation("inputs")>]
178-
member this.Inputs (spec: CommandSpec<'T, 'Output>, (a: HandlerInput<'A>, b: HandlerInput<'B>, c: HandlerInput<'C>, d: HandlerInput<'D>, e: HandlerInput<'E>, f: HandlerInput<'F>, g: HandlerInput<'G>, h: HandlerInput<'H>)) =
178+
member this.Inputs (spec: CommandSpec<'T, 'Output>, (a: ActionInput<'A>, b: ActionInput<'B>, c: ActionInput<'C>, d: ActionInput<'D>, e: ActionInput<'E>, f: ActionInput<'F>, g: ActionInput<'G>, h: ActionInput<'H>)) =
179179
{ newHandler def<'A * 'B * 'C * 'D * 'E * 'F * 'G * 'H -> 'Output> spec with Inputs = [ a; b; c; d; e; f; g; h ] }
180180

181181
/// Sets a handler function that takes a tuple of inputs (max. 8). NOTE: This must be set after the inputs.
@@ -215,11 +215,11 @@ type BaseCommandBuilder<'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'Output>() =
215215
) spec
216216

217217
[<CustomOperation("addGlobalOption")>]
218-
member this.AddGlobalOption (spec: CommandSpec<'Inputs, 'Output>, globalInput: HandlerInput) =
218+
member this.AddGlobalOption (spec: CommandSpec<'Inputs, 'Output>, globalInput: ActionInput) =
219219
{ spec with GlobalInputs = spec.GlobalInputs @ [ globalInput ] }
220220

221221
[<CustomOperation("addGlobalOptions")>]
222-
member this.AddGlobalOptions (spec: CommandSpec<'Inputs, 'Output>, globalInputs: HandlerInput seq) =
222+
member this.AddGlobalOptions (spec: CommandSpec<'Inputs, 'Output>, globalInputs: ActionInput seq) =
223223
{ spec with GlobalInputs = spec.GlobalInputs @ (globalInputs |> List.ofSeq) }
224224

225225
[<Obsolete("'setCommand' has been deprecated in favor of 'addCommand' or 'addCommands'.")>]
@@ -249,12 +249,12 @@ type BaseCommandBuilder<'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'Output>() =
249249

250250
/// Adds an extra input (when more than 8 inputs are required).
251251
[<CustomOperation("addInput")>]
252-
member this.AddInput(spec: CommandSpec<'Inputs, 'Output>, extraInput: HandlerInput) =
252+
member this.AddInput(spec: CommandSpec<'Inputs, 'Output>, extraInput: ActionInput) =
253253
{ spec with ExtraInputs = spec.ExtraInputs @ [ extraInput ] }
254254

255255
/// Adds extra inputs (when more than 8 inputs are required).
256256
[<CustomOperation("addInputs")>]
257-
member this.AddInputs(spec: CommandSpec<'Inputs, 'Output>, extraInputs: HandlerInput seq) =
257+
member this.AddInputs(spec: CommandSpec<'Inputs, 'Output>, extraInputs: ActionInput seq) =
258258
{ spec with ExtraInputs = spec.ExtraInputs @ (extraInputs |> List.ofSeq) }
259259

260260
/// Sets general properties on the command.

src/FSharp.SystemCommandLine/Inputs.fs

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@ type ActionContext =
2525
CancellationToken = System.Threading.CancellationToken.None
2626
}
2727

28-
type HandlerInputSource =
28+
type ActionInputSource =
2929
| ParsedOption of Option
3030
| ParsedArgument of Argument
3131
| Context
3232

33-
type HandlerInput(source: HandlerInputSource) =
33+
type ActionInput(source: ActionInputSource) =
3434
member this.Source = source
3535

36-
type HandlerInput<'T>(inputType: HandlerInputSource) =
37-
inherit HandlerInput(inputType)
36+
type ActionInput<'T>(inputType: ActionInputSource) =
37+
inherit ActionInput(inputType)
3838

3939
/// Converts a System.CommandLine.Option<'T> for usage with the CommandBuilder.
40-
static member OfOption<'T>(o: Option<'T>) = o :> Option |> ParsedOption |> HandlerInput<'T>
40+
static member OfOption<'T>(o: Option<'T>) = o :> Option |> ParsedOption |> ActionInput<'T>
4141

4242
/// Converts a System.CommandLine.Argument<'T> for usage with the CommandBuilder.
43-
static member OfArgument<'T>(a: Argument<'T>) = a :> Argument |> ParsedArgument |> HandlerInput<'T>
43+
static member OfArgument<'T>(a: Argument<'T>) = a :> Argument |> ParsedArgument |> ActionInput<'T>
4444

4545
/// Gets the value of an Option or Argument from the Parser.
4646
member this.GetValue(parseResult: ParseResult) =
@@ -52,47 +52,47 @@ type HandlerInput<'T>(inputType: HandlerInputSource) =
5252
module Input =
5353

5454
let context =
55-
HandlerInput<ActionContext>(Context)
55+
ActionInput<ActionContext>(Context)
5656

5757
let option<'T> (name: string) =
58-
Option<'T>(name) |> HandlerInput.OfOption
58+
Option<'T>(name) |> ActionInput.OfOption
5959

60-
let editOption (edit: Option<'T> -> unit) (hi: HandlerInput<'T>) =
60+
let editOption (edit: Option<'T> -> unit) (hi: ActionInput<'T>) =
6161
match hi.Source with
6262
| ParsedOption o -> o :?> Option<'T> |> edit
6363
| _ -> ()
6464
hi
6565

66-
let editArgument (edit: Argument<'T> -> unit) (hi: HandlerInput<'T>) =
66+
let editArgument (edit: Argument<'T> -> unit) (hi: ActionInput<'T>) =
6767
match hi.Source with
6868
| ParsedArgument a -> a :?> Argument<'T> |> edit
6969
| _ -> ()
7070
hi
7171

72-
let aliases (aliases: string seq) (hi: HandlerInput<'T>) =
72+
let aliases (aliases: string seq) (hi: ActionInput<'T>) =
7373
hi |> editOption (fun o -> aliases |> Seq.iter o.Aliases.Add)
7474

75-
let alias (alias: string) (hi: HandlerInput<'T>) =
75+
let alias (alias: string) (hi: ActionInput<'T>) =
7676
hi |> editOption (fun o -> o.Aliases.Add alias)
7777

78-
let desc (description: string) (hi: HandlerInput<'T>) =
78+
let desc (description: string) (hi: ActionInput<'T>) =
7979
hi
8080
|> editOption (fun o -> o.Description <- description)
8181
|> editArgument (fun a -> a.Description <- description)
8282

83-
let defaultValue (defaultValue: 'T) (hi: HandlerInput<'T>) =
83+
let defaultValue (defaultValue: 'T) (hi: ActionInput<'T>) =
8484
hi
8585
|> editOption (fun o -> o.DefaultValueFactory <- (fun _ -> defaultValue))
8686
|> editArgument (fun a -> a.DefaultValueFactory <- (fun _ -> defaultValue))
8787

8888
let def = defaultValue
8989

90-
let defFactory (defaultValueFactory: Parsing.ArgumentResult -> 'T) (hi: HandlerInput<'T>) =
90+
let defFactory (defaultValueFactory: Parsing.ArgumentResult -> 'T) (hi: ActionInput<'T>) =
9191
hi
9292
|> editOption (fun o -> o.DefaultValueFactory <- defaultValueFactory)
9393
|> editArgument (fun a -> a.DefaultValueFactory <- defaultValueFactory)
9494

95-
let required (hi: HandlerInput<'T>) =
95+
let required (hi: ActionInput<'T>) =
9696
hi |> editOption (fun o -> o.Required <- true)
9797

9898
let optionMaybe<'T> (name: string) =
@@ -107,11 +107,11 @@ module Input =
107107
)
108108
o.Arity <- ArgumentArity(0, 1)
109109
o.DefaultValueFactory <- (fun _ -> None)
110-
HandlerInput.OfOption<'T option> o
110+
ActionInput.OfOption<'T option> o
111111

112112
let argument<'T> (name: string) =
113113
let a = Argument<'T>(name)
114-
HandlerInput.OfArgument<'T> a
114+
ActionInput.OfArgument<'T> a
115115

116116
let argumentMaybe<'T> (name: string) =
117117
let a = Argument<'T option>(name)
@@ -122,104 +122,104 @@ module Input =
122122
| [ token ] -> MaybeParser.parseTokenValue token.Value
123123
| _ :: _ -> failwith "F# Option can only be used with a single argument."
124124
)
125-
HandlerInput.OfArgument<'T option> a
125+
ActionInput.OfArgument<'T option> a
126126

127127
let ofOption (o: Option<'T>) =
128-
HandlerInput.OfOption<'T> o
128+
ActionInput.OfOption<'T> o
129129

130130
let ofArgument (a: Argument<'T>) =
131-
HandlerInput.OfArgument<'T> a
131+
ActionInput.OfArgument<'T> a
132132

133133
/// Creates CLI options and arguments to be passed as command `inputs`.
134134
type Input =
135135

136136
/// Converts a System.CommandLine.Option<'T> for usage with the CommandBuilder.
137137
[<Obsolete("Use Input.ofOption instead")>]
138-
static member OfOption<'T>(o: Option<'T>) : HandlerInput<'T> =
138+
static member OfOption<'T>(o: Option<'T>) : ActionInput<'T> =
139139
invalidOp "This method has been removed."
140140

141141
/// Converts a System.CommandLine.Argument<'T> for usage with the CommandBuilder.
142142
[<Obsolete("Use Input.ofArgument instead")>]
143-
static member OfArgument<'T>(a: Argument<'T>) : HandlerInput<'T> =
143+
static member OfArgument<'T>(a: Argument<'T>) : ActionInput<'T> =
144144
invalidOp "This method has been removed."
145145

146146
/// Creates a CLI option of type 'T with the ability to manually configure the underlying properties.
147147
[<Obsolete "Use Input.option instead.">]
148-
static member Option<'T>(name: string, configure: Option<'T> -> unit) : HandlerInput<'T> =
148+
static member Option<'T>(name: string, configure: Option<'T> -> unit) : ActionInput<'T> =
149149
invalidOp "This method has been removed."
150150

151151
/// Creates a CLI option of type 'T with the ability to manually configure the underlying properties.
152152
[<Obsolete "Use Input.option instead.">]
153-
static member Option<'T>(aliases: string seq, configure: Option<'T> -> unit) : HandlerInput<'T> =
153+
static member Option<'T>(aliases: string seq, configure: Option<'T> -> unit) : ActionInput<'T> =
154154
invalidOp "This method has been removed."
155155

156156
/// Creates a CLI argument of type 'T with the ability to manually configure the underlying properties.
157157
[<Obsolete "Use Input.argument instead.">]
158-
static member Argument<'T>(name: string, configure: Argument<'T> -> unit) : HandlerInput<'T> =
158+
static member Argument<'T>(name: string, configure: Argument<'T> -> unit) : ActionInput<'T> =
159159
invalidOp "This method has been removed."
160160

161161
/// Creates a CLI option of type 'T.
162162
[<Obsolete "Use Input.option instead.">]
163-
static member Option<'T>(name: string, ?description: string) : HandlerInput<'T> =
163+
static member Option<'T>(name: string, ?description: string) : ActionInput<'T> =
164164
invalidOp "This method has been removed."
165165

166166
/// Creates a CLI option of type 'T.
167167
[<Obsolete "Use Input.option instead.">]
168-
static member Option<'T>(aliases: string seq, ?description: string) : HandlerInput<'T> =
168+
static member Option<'T>(aliases: string seq, ?description: string) : ActionInput<'T> =
169169
invalidOp "This method has been removed."
170170

171171
/// Creates a CLI option of type 'T with a default value.
172172
[<Obsolete "Use Input.option instead.">]
173-
static member Option<'T>(name: string, defaultValue: 'T, ?description: string) : HandlerInput<'T> =
173+
static member Option<'T>(name: string, defaultValue: 'T, ?description: string) : ActionInput<'T> =
174174
invalidOp "This method has been removed."
175175

176176
/// Creates a CLI option of type 'T with a default value.
177177
[<Obsolete "Use Input.option instead.">]
178-
static member Option<'T>(aliases: string seq, defaultValue: 'T, ?description: string) : HandlerInput<'T> =
178+
static member Option<'T>(aliases: string seq, defaultValue: 'T, ?description: string) : ActionInput<'T> =
179179
invalidOp "This method has been removed."
180180

181181
/// Creates a CLI option of type 'T that is required.
182182
[<Obsolete "Use Input.option + Input.required instead.">]
183-
static member OptionRequired<'T>(aliases: string seq, ?description: string) : HandlerInput<'T> =
183+
static member OptionRequired<'T>(aliases: string seq, ?description: string) : ActionInput<'T> =
184184
invalidOp "This method has been removed."
185185

186186
/// Creates a CLI option of type 'T that is required.
187187
[<Obsolete "Use Input.option + Input.required instead.">]
188-
static member OptionRequired<'T>(name: string, ?description: string) : HandlerInput<'T> =
188+
static member OptionRequired<'T>(name: string, ?description: string) : ActionInput<'T> =
189189
invalidOp "This method has been removed."
190190

191191
/// Creates a CLI option of type 'T option with the ability to manually configure the underlying properties.
192192
[<Obsolete "Use Input.optionMaybe instead.">]
193-
static member OptionMaybe<'T>(aliases: string seq, configure: Option<'T option> -> unit) : HandlerInput<'T option> =
193+
static member OptionMaybe<'T>(aliases: string seq, configure: Option<'T option> -> unit) : ActionInput<'T option> =
194194
invalidOp "This method has been removed."
195195

196196
/// Creates a CLI option of type 'T option with the ability to manually configure the underlying properties.
197197
[<Obsolete "Use Input.optionMaybe instead.">]
198-
static member OptionMaybe<'T>(name: string, configure: Option<'T option> -> unit) : HandlerInput<'T option> =
198+
static member OptionMaybe<'T>(name: string, configure: Option<'T option> -> unit) : ActionInput<'T option> =
199199
invalidOp "This method has been removed."
200200

201201
/// Creates a CLI option of type 'T option.
202202
[<Obsolete "Use Input.optionMaybe instead.">]
203-
static member OptionMaybe<'T>(aliases: string seq, ?description: string) : HandlerInput<'T option> =
203+
static member OptionMaybe<'T>(aliases: string seq, ?description: string) : ActionInput<'T option> =
204204
invalidOp "This method has been removed."
205205

206206
/// Creates a CLI option of type 'T option.
207-
static member OptionMaybe<'T>(name: string, ?description: string) : HandlerInput<'T option> =
207+
static member OptionMaybe<'T>(name: string, ?description: string) : ActionInput<'T option> =
208208
invalidOp "This method has been removed."
209209

210210
/// Creates a CLI argument of type 'T.
211211
[<Obsolete "Use Input.argument instead.">]
212-
static member Argument<'T>(name: string, ?description: string) : HandlerInput<'T> =
212+
static member Argument<'T>(name: string, ?description: string) : ActionInput<'T> =
213213
invalidOp "This method has been removed."
214214

215215
/// Creates a CLI argument of type 'T with a default value.
216216
[<Obsolete "Use Input.argument instead.">]
217-
static member Argument<'T>(name: string, defaultValue: 'T, ?description: string) : HandlerInput<'T> =
217+
static member Argument<'T>(name: string, defaultValue: 'T, ?description: string) : ActionInput<'T> =
218218
invalidOp "This method has been removed."
219219

220220
/// Creates a CLI argument of type 'T option.
221221
[<Obsolete "Use Input.argumentMaybe instead.">]
222-
static member ArgumentMaybe<'T>(name: string, ?description: string) : HandlerInput<'T option> =
222+
static member ArgumentMaybe<'T>(name: string, ?description: string) : ActionInput<'T option> =
223223
invalidOp "This method has been removed."
224224

225225
/// Passes the `InvocationContext` to the handler.

src/TestConsole/ProgramNestedSubCommands.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module Global =
1010

1111
type Options = { EnableLogging: bool; LogFile: FileInfo }
1212

13-
let options: HandlerInput seq = [ enableLogging; logFile ]
13+
let options: ActionInput seq = [ enableLogging; logFile ]
1414

1515
let bind parseResult =
1616
{ EnableLogging = enableLogging.GetValue parseResult

0 commit comments

Comments
 (0)