@@ -252,9 +252,48 @@ type BaseCommandBuilder<'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'I, 'J, 'K, 'L, 'M, 'N,
252252 | 16 -> cmd.SetHandler( Func< 'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'I, 'J, 'K, 'L, 'M, 'N, 'O, 'P, Task>( fun a b c d e f g h i j k l m n o p -> handler ( a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)), inputs)
253253 | _ -> raise ( NotImplementedException())
254254 cmd
255+
255256
256-
257- /// Builds a ` System.CommandLine.RootCommand ` .
257+ /// Builds a ` System.CommandLine.Parsing.Parser ` .
258+ type RootCommandParserBuilder < 'A , 'B , 'C , 'D , 'E , 'F , 'G , 'H , 'I , 'J , 'K , 'L , 'M , 'N , 'O , 'P , 'Output >() =
259+ inherit BaseCommandBuilder< 'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'I, 'J, 'K, 'L, 'M, 'N, 'O, 'P, 'Output>()
260+
261+ [<CustomOperation( " usePipeline" ) >]
262+ member this.UsePipeline ( spec : CommandSpec < 'Inputs , 'Output >, subCommand : CommandLineBuilder -> unit ) =
263+ subCommand this.CommandLineBuilder
264+ spec
265+
266+ [<CustomOperation( " usePipeline" ) >]
267+ member this.UsePipeline ( spec : CommandSpec < 'Inputs , 'Output >, subCommand : CommandLineBuilder -> CommandLineBuilder ) =
268+ this.CommandLineBuilder <- subCommand this.CommandLineBuilder
269+ spec
270+
271+ /// Executes a Command with a handler that returns unit.
272+ member this.Run ( spec : CommandSpec < 'Inputs , unit >) =
273+ this.CommandLineBuilder.Command
274+ |> this.SetGeneralProperties spec
275+ |> this.SetActionHandler spec
276+ |> ignore
277+ this.CommandLineBuilder.Build()
278+
279+ /// Executes a Command with a handler that returns int.
280+ member this.Run ( spec : CommandSpec < 'Inputs , int >) =
281+ this.CommandLineBuilder.Command
282+ |> this.SetGeneralProperties spec
283+ |> this.SetFuncHandlerSync spec
284+ |> ignore
285+ this.CommandLineBuilder.Build()
286+
287+ /// Executes a Command with a handler that returns a Task<unit > or Task<int >.
288+ member this.Run ( spec : CommandSpec < 'Inputs , Task < 'ReturnValue >>) =
289+ this.CommandLineBuilder.Command
290+ |> this.SetGeneralProperties spec
291+ |> this.SetFuncHandlerAsync spec
292+ |> ignore
293+ this.CommandLineBuilder.Build()
294+
295+
296+ /// Builds and executes a ` System.CommandLine.RootCommand ` .
258297type RootCommandBuilder < 'A , 'B , 'C , 'D , 'E , 'F , 'G , 'H , 'I , 'J , 'K , 'L , 'M , 'N , 'O , 'P , 'Output >( args : string array ) =
259298 inherit BaseCommandBuilder< 'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'I, 'J, 'K, 'L, 'M, 'N, 'O, 'P, 'Output>()
260299
@@ -317,6 +356,10 @@ type CommandBuilder<'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'I, 'J, 'K, 'L, 'M, 'N, 'O,
317356
318357
319358/// Builds a ` System.CommandLine.RootCommand ` using computation expression syntax.
359+ let rootCommandParser < 'A , 'B , 'C , 'D , 'E , 'F , 'G , 'H , 'I , 'J , 'K , 'L , 'M , 'N , 'O , 'P , 'Output > =
360+ RootCommandParserBuilder< 'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'I, 'J, 'K, 'L, 'M, 'N, 'O, 'P, 'Output>()
361+
362+ /// Builds and executes a ` System.CommandLine.RootCommand ` using computation expression syntax.
320363let rootCommand < 'A , 'B , 'C , 'D , 'E , 'F , 'G , 'H , 'I , 'J , 'K , 'L , 'M , 'N , 'O , 'P , 'Output >( args : string array )=
321364 RootCommandBuilder< 'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'I, 'J, 'K, 'L, 'M, 'N, 'O, 'P, 'Output>( args)
322365
0 commit comments