@@ -52,7 +52,7 @@ type ShellBuilder() =
5252
5353 member t.Yield _ = ExecOptions.Empty
5454
55- [<CustomOperation( " workingDirectory " ) >]
55+ [<CustomOperation( " working_dir " ) >]
5656 member inline this.WorkingDirectory ( opts , workingDirectory : string ) =
5757 { opts with WorkingDirectory = Some workingDirectory }
5858
@@ -90,54 +90,126 @@ type ShellBuilder() =
9090 Proc.Exec( execArgs) |> ignore
9191 opts
9292
93+
9394let shell = ShellBuilder()
9495
96+ type TempBuilder () =
97+
98+ member t.Yield _ = ExecOptions.Empty
99+
100+ [<CustomOperation( " run" ) >]
101+ member this.Run2 ( opts , binary , [<ParamArray>] args : string array ) =
102+ let opts = { opts with Binary = binary; Arguments = Some ( args |> List.ofArray)}
103+ let execArgs = execArgs opts
104+ Proc.Exec( execArgs) |> ignore
105+
106+ [<CustomOperation( " run" ) >]
107+ member this.Run2 ( opts , binary , args : string list ) =
108+ let opts = { opts with Binary = binary; Arguments = Some args}
109+ let execArgs = execArgs opts
110+ Proc.Exec( execArgs) |> ignore
111+
112+ [<CustomOperation( " run" ) >]
113+ member this.Run2 ( opts ) =
114+ let execArgs = execArgs opts
115+ Proc.Exec( execArgs) |> ignore
116+
117+ let temp = TempBuilder()
118+
119+
95120type ExecBuilder () =
96121
97122 member t.Yield _ = ExecOptions.Empty
98123
124+ ///<summary>Runs <paramref name="binary"/> using <paramref name="arguments"/> immediately</summary>
125+ /// <param name="opts"><see cref="ExecOptions"/> the computation build thus far, not specified directly</param>
126+ /// <param name="binary">The binary to execute</param>
127+ /// <param name="arguments">the arguments to pass on to the binary being executed</param>
128+ [<CustomOperation( " run" ) >]
129+ member this.Execute ( opts , binary , [<ParamArray>] arguments : string array ) =
130+ let opts = { opts with Binary = binary; Arguments = Some ( arguments |> List.ofArray)}
131+ let execArgs = execArgs opts
132+ Proc.Exec( execArgs) |> ignore
133+
134+ ///<summary>Runs <paramref name="binary"/> using <paramref name="arguments"/> immediately</summary>
135+ /// <param name="opts"><see cref="ExecOptions"/> the computation build thus far, not specified directly</param>
136+ /// <param name="binary">The binary to execute</param>
137+ /// <param name="arguments">the arguments to pass on to the binary being executed</param>
138+ [<CustomOperation( " run" ) >]
139+ member this.Execute ( opts , binary , arguments : string list ) =
140+ let opts = { opts with Binary = binary; Arguments = Some arguments}
141+ let execArgs = execArgs opts
142+ Proc.Exec( execArgs) |> ignore
143+
144+ ///<summary>
145+ /// Runs the <see cref="ExecOptions"/> the computation build thus far.
146+ /// <para>Needs at least `binary` to be specified</para>
147+ /// </summary>
148+ [<CustomOperation( " run" ) >]
149+ member this.Execute ( opts ) =
150+ if opts.Binary = " " then failwithf " No binary specified to exec computation expression"
151+ let execArgs = execArgs opts
152+ Proc.Exec( execArgs) |> ignore
153+
154+ ///<summary>Supply external <see cref="ExecOptions"/> to bootstrap</summary>
155+ [<CustomOperation( " options" ) >]
156+ member this.Options ( _ , reuseOptions : ExecOptions ) =
157+ reuseOptions
158+
159+ ///<summary>The binary to execute</summary>
160+ /// <param name="opts"><see cref="ExecOptions"/> the computation build thus far, not specified directly</param>
161+ /// <param name="binary">The binary to execute</param>
99162 [<CustomOperation( " binary" ) >]
100163 member this.Binary ( opts , binary ) =
101164 { opts with Binary = binary }
102165
103- [<CustomOperation( " args" ) >]
104- member inline this.Arguments ( opts , [<ParamArray>] args : string array ) =
105- { opts with Arguments = Some ( args |> List.ofArray) }
106-
107- [<CustomOperation( " args" ) >]
108- member inline this.Arguments ( opts , args : string list ) =
109- { opts with Arguments = Some args}
110-
111- [<CustomOperation( " workingDirectory" ) >]
112- member inline this.WorkingDirectory ( opts , workingDirectory : string ) =
166+ ///<summary>The arguments to call the binary with</summary>
167+ /// <param name="opts"><see cref="ExecOptions"/> the computation build thus far, not specified directly</param>
168+ /// <param name="arguments">The arguments to call the binary with</param>
169+ [<CustomOperation( " arguments" ) >]
170+ member this.Arguments ( opts , [<ParamArray>] arguments : string array ) =
171+ { opts with Arguments = Some ( arguments |> List.ofArray) }
172+
173+ ///<summary>The arguments to call the binary with</summary>
174+ /// <param name="opts"><see cref="ExecOptions"/> the computation build thus far, not specified directly</param>
175+ /// <param name="arguments">The arguments to call the binary with</param>
176+ [<CustomOperation( " arguments" ) >]
177+ member this.Arguments ( opts , arguments : string list ) =
178+ { opts with Arguments = Some arguments}
179+
180+ ///<summary>Specify a working directory to start the execution of the binary in</summary>
181+ /// <param name="opts"><see cref="ExecOptions"/> the computation build thus far, not specified directly</param>
182+ /// <param name="workingDirectory">Specify a working directory to start the execution of the binary in</param>
183+ [<CustomOperation( " working_dir" ) >]
184+ member this.WorkingDirectory ( opts , workingDirectory : string ) =
113185 { opts with WorkingDirectory = Some workingDirectory }
114186
115187 [<CustomOperation( " env" ) >]
116- member inline this.EnvironmentVariables ( opts , env : Map < string , string >) =
188+ member this.EnvironmentVariables ( opts , env : Map < string , string >) =
117189 { opts with Environment = Some env }
118190
119191 [<CustomOperation( " timeout" ) >]
120- member inline this.Timeout ( opts , timeout ) =
192+ member this.Timeout ( opts , timeout ) =
121193 { opts with Timeout = Some timeout }
122194
123195 [<CustomOperation( " stream_reader_wait_timeout" ) >]
124- member inline this.WaitForStreamReadersTimeout ( opts , timeout ) =
196+ member this.WaitForStreamReadersTimeout ( opts , timeout ) =
125197 { opts with WaitForStreamReadersTimeout = Some timeout }
126198
127199 [<CustomOperation( " send_control_c" ) >]
128- member inline this.SendControlCFirst ( opts , sendControlCFirst ) =
200+ member this.SendControlCFirst ( opts , sendControlCFirst ) =
129201 { opts with SendControlCFirst = Some sendControlCFirst }
130202
131203 [<CustomOperation( " thread_wrap" ) >]
132- member inline this.NoWrapInThread ( opts , threadWrap ) =
204+ member this.NoWrapInThread ( opts , threadWrap ) =
133205 { opts with NoWrapInThread = Some ( not threadWrap) }
134206
135207 [<CustomOperation( " filter_output" ) >]
136- member inline this.FilterOutput ( opts , find : LineOut -> bool ) =
208+ member this.FilterOutput ( opts , find : LineOut -> bool ) =
137209 { opts with LineOutFilter = Some find }
138210
139211 [<CustomOperation( " validExitCode" ) >]
140- member inline this.ValidExitCode ( opts , exitCodeClassifier : int -> bool ) =
212+ member this.ValidExitCode ( opts , exitCodeClassifier : int -> bool ) =
141213 { opts with ValidExitCodeClassifier = Some exitCodeClassifier }
142214
143215 [<CustomOperation( " find" ) >]
@@ -163,43 +235,26 @@ type ExecBuilder() =
163235 Proc.Start( startArguments)
164236
165237 [<CustomOperation( " run_args" ) >]
166- member this.InvokeArgs ( opts , [<ParamArray>] args : string array ) =
167- let opts = { opts with Arguments = Some ( args |> List.ofArray) }
238+ member this.InvokeArgs ( opts , [<ParamArray>] arguments : string array ) =
239+ let opts = { opts with Arguments = Some ( arguments |> List.ofArray) }
168240 let execArgs = execArgs opts
169241 Proc.Exec( execArgs) |> ignore
170242
171243 [<CustomOperation( " run_args" ) >]
172- member this.InvokeArgs ( opts , args : string list ) =
173- let opts = { opts with Arguments = Some args}
174- let execArgs = execArgs opts
175- Proc.Exec( execArgs) |> ignore
176-
177- [<CustomOperation( " run" ) >]
178- member this.Execute ( opts ) =
179- let execArgs = execArgs opts
180- Proc.Exec( execArgs) |> ignore
181-
182- [<CustomOperation( " run" ) >]
183- member this.Execute ( opts , binary , args : string list ) =
184- let opts = { opts with Binary = binary; Arguments = Some args}
185- let execArgs = execArgs opts
186- Proc.Exec( execArgs) |> ignore
187-
188- [<CustomOperation( " run" ) >]
189- member this.Execute ( opts , binary , [<ParamArray>] args : string array ) =
190- let opts = { opts with Binary = binary; Arguments = Some ( args |> List.ofArray)}
244+ member this.InvokeArgs ( opts , arguments : string list ) =
245+ let opts = { opts with Arguments = Some arguments}
191246 let execArgs = execArgs opts
192247 Proc.Exec( execArgs) |> ignore
193248
194249 [<CustomOperation( " exit_code_of" ) >]
195- member this.ReturnStatus ( opts , binary , args : string list ) =
196- let opts = { opts with Binary = binary; Arguments = Some args }
250+ member this.ReturnStatus ( opts , binary , arguments : string list ) =
251+ let opts = { opts with Binary = binary; Arguments = Some arguments }
197252 let execArgs = execArgs opts
198253 Proc.Exec( execArgs) .GetValueOrDefault 1
199254
200255 [<CustomOperation( " exit_code_of" ) >]
201- member this.ReturnStatus ( opts , binary , [<ParamArray>] args : string array ) =
202- let opts = { opts with Binary = binary; Arguments = Some ( args |> List.ofArray)}
256+ member this.ReturnStatus ( opts , binary , [<ParamArray>] arguments : string array ) =
257+ let opts = { opts with Binary = binary; Arguments = Some ( arguments |> List.ofArray)}
203258 let execArgs = execArgs opts
204259 Proc.Exec( execArgs) .GetValueOrDefault 1
205260
@@ -209,16 +264,16 @@ type ExecBuilder() =
209264 Proc.Exec( execArgs) .GetValueOrDefault 1
210265
211266 [<CustomOperation( " output_of" ) >]
212- member this.ReturnOutput ( opts , binary , [<ParamArray>] args : string array ) =
213- let opts = { opts with Binary = binary; Arguments = Some ( args |> List.ofArray)}
267+ member this.ReturnOutput ( opts , binary , [<ParamArray>] arguments : string array ) =
268+ let opts = { opts with Binary = binary; Arguments = Some ( arguments |> List.ofArray)}
214269 let execArgs = startArgs opts
215270 Proc.Start( execArgs)
216271
217272 [<CustomOperation( " output_of" ) >]
218273 member this.ReturnOutput ( opts ) =
219274 let startArgs = startArgs opts
220275 Proc.Start( startArgs)
221-
276+
222277
223278let exec = ExecBuilder()
224279
0 commit comments