@@ -56,47 +56,6 @@ Notice that mismatches between the `setHandler` and the `inputs` are caught as a
5656![ cli safety] ( https://user-images.githubusercontent.com/1030435/158190730-b1ae0bbf-825b-48c4-b267-05a1853de4d9.gif )
5757
5858
59- ### Async App with a Dependency and Pipeline Override
60-
61- ``` F#
62- open FSharp.SystemCommandLine
63- open System.CommandLine.Builder
64- open System.Threading.Tasks
65-
66- type WordService() =
67- member _.Join(separator: string, words: string array) =
68- task {
69- do! Task.Delay(1000)
70- return System.String.Join(separator, words)
71- }
72-
73- let app (svc: WordService) (words: string array, separator: string) =
74- task {
75- let! result = svc.Join(separator, words)
76- result |> printfn "Result: %s"
77- }
78-
79- [<EntryPoint>]
80- let main argv =
81- let words = Input.Option(["--word"; "-w"], Array.empty, "A list of words to be appended")
82- let separator = Input.Option(["--separator"; "-s"], ", ", "A character that will separate the joined words.")
83-
84- // Initialize app dependencies
85- let svc = WordService()
86-
87- rootCommand argv {
88- description "Appends words together"
89- inputs (words, separator)
90- usePipeline (fun builder ->
91- CommandLineBuilder() // Pipeline is initialized with .UseDefaults() by default,
92- .UseTypoCorrections(3) // but you can override it here if needed.
93- )
94- setHandler (app svc) // Partially apply app dependencies
95- }
96- |> Async.AwaitTask
97- |> Async.RunSynchronously
98- ```
99-
10059### App with SubCommands
10160
10261``` F#
@@ -159,3 +118,45 @@ let main argv =
159118> TestConsole delete "c:\_github\FSharp.SystemCommandLine\src\FSharp.SystemCommandLine" --recursive
160119 Recursively deleting c:\_github\FSharp.SystemCommandLine\src\FSharp.SystemCommandLine
161120```
121+
122+
123+ ### Async App with a Partially Applied Dependency
124+
125+ ``` F#
126+ open FSharp.SystemCommandLine
127+ open System.CommandLine.Builder
128+ open System.Threading.Tasks
129+
130+ type WordService() =
131+ member _.Join(separator: string, words: string array) =
132+ task {
133+ do! Task.Delay(1000)
134+ return System.String.Join(separator, words)
135+ }
136+
137+ let app (svc: WordService) (words: string array, separator: string) =
138+ task {
139+ let! result = svc.Join(separator, words)
140+ result |> printfn "Result: %s"
141+ }
142+
143+ [<EntryPoint>]
144+ let main argv =
145+ let words = Input.Option(["--word"; "-w"], Array.empty, "A list of words to be appended")
146+ let separator = Input.Option(["--separator"; "-s"], ", ", "A character that will separate the joined words.")
147+
148+ // Initialize app dependencies
149+ let svc = WordService()
150+
151+ rootCommand argv {
152+ description "Appends words together"
153+ inputs (words, separator)
154+ usePipeline (fun builder ->
155+ CommandLineBuilder() // Pipeline is initialized with .UseDefaults() by default,
156+ .UseTypoCorrections(3) // but you can override it here if needed.
157+ )
158+ setHandler (app svc) // Partially apply app dependencies
159+ }
160+ |> Async.AwaitTask
161+ |> Async.RunSynchronously
162+ ```
0 commit comments