Skip to content

Commit ed72875

Browse files
committed
Handlers can now return a code.
1 parent b1ca520 commit ed72875

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/FSharp.SystemCommandLine/CommandBuilders.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,11 @@ type BaseCommandBuilder<'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'I, 'J, 'K, 'L, 'M, 'N,
156156
cmd
157157

158158
/// Sets a command handler that returns a Task.
159-
member this.SetFuncHandler (spec: CommandSpec<'Inputs, Task<unit>>) (cmd: Command) =
159+
member this.SetFuncHandler (spec: CommandSpec<'Inputs, Task<'ReturnValue>>) (cmd: Command) =
160160
let inputs = spec.Inputs |> List.toArray
161161
let handler (args: obj) =
162162
task {
163-
do! spec.Handler (args :?> 'Inputs)
163+
return! spec.Handler (args :?> 'Inputs)
164164
}
165165

166166
match spec.Inputs.Length with
@@ -208,7 +208,7 @@ type RootCommandBuilder<'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'I, 'J, 'K, 'L, 'M, 'N,
208208
this.CommandLineBuilder.Build().Parse(args).Invoke()
209209

210210
/// Executes a Command with a handler that returns a Task.
211-
member this.Run (spec: CommandSpec<'Inputs, Task<unit>>) =
211+
member this.Run (spec: CommandSpec<'Inputs, Task<'ReturnValue>>) =
212212
this.CommandLineBuilder.Command
213213
|> this.SetGeneralProperties spec
214214
|> this.SetFuncHandler spec
@@ -227,7 +227,7 @@ type CommandBuilder<'A, 'B, 'C, 'D, 'E, 'F, 'G, 'H, 'I, 'J, 'K, 'L, 'M, 'N, 'O,
227227
|> this.SetActionHandler spec
228228

229229
/// Returns a Command with a handler that returns a Task.
230-
member this.Run (spec: CommandSpec<'Inputs, Task<unit>>) =
230+
member this.Run (spec: CommandSpec<'Inputs, Task<'ReturnValue>>) =
231231
Command(name)
232232
|> this.SetGeneralProperties spec
233233
|> this.SetFuncHandler spec

0 commit comments

Comments
 (0)