Nuke.Cola
Loading...
Searching...
No Matches
ToolCola.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using Nuke.Common;
7using Nuke.Common.IO;
8using Nuke.Common.Tooling;
9using Nuke.Common.Utilities;
10using Serilog;
11
12namespace Nuke.Cola.Tooling;
13
14public static class ToolCola
15{
16 /// <summary>
17 /// Execute a tool with the arguments provided by the input record.
18 /// </summary>
19 /// <param name="tool"></param>
20 /// <param name="args"></param>
21 public static IReadOnlyCollection<Output> ExecuteWith(this Tool tool, ToolArguments args)
22 => tool(
23 $"{args.Arguments:nq}",
24 args.WorkingDirectory,
25 args.EnvironmentVariables,
26 args.Timeout,
27 args.LogOutput,
28 args.LogInvocation,
29 args.Logger,
30 args.ExitHandler
31 );
32
33 /// <summary>
34 /// Execute a tool with standard input with the arguments provided by the input record.
35 /// </summary>
36 /// <param name="tool"></param>
37 /// <param name="args"></param>
38 public static IReadOnlyCollection<Output>? ExecuteWith(this ToolEx tool, ToolExArguments args)
39 => tool(
40 $"{args.ToolArgs.Arguments:nq}",
41 args.ToolArgs.WorkingDirectory,
42 args.ToolArgs.EnvironmentVariables,
43 args.ToolArgs.Timeout,
44 args.ToolArgs.LogOutput,
45 args.ToolArgs.LogInvocation,
46 args.ToolArgs.Logger,
47 args.ToolArgs.ExitHandler,
48 args.Input
49 );
50
51 /// <summary>
52 /// Set individual Tool launching parameters and propagate the delegate further
53 /// </summary>
54 /// <param name="tool"></param>
55 /// <param name="args"></param>
56 /// <remarks>
57 /// <list>
58 /// <item><term>Arguments </term><description> will be concatenated</description></item>
59 /// <item><term>Working directory </term><description> B overrides the one from A but not when B doesn't have one</description></item>
60 /// <item><term>Environmnent variables </term><description> will be merged</description></item>
61 /// <item><term>TimeOut </term><description> will be maxed</description></item>
62 /// <item><term>LogOutput </term><description> is OR-ed</description></item>
63 /// <item><term>LogInvocation </term><description> is OR-ed</description></item>
64 /// <item><term>Logger / ExitHandler </term><description>A + B is invoked</description></item>
65 /// </list>
66 /// </remarks>
67 public static Tool With(this Tool tool, ToolArguments args)
68 => new PropagateToolExecution(tool, args).Execute;
69
70 /// <summary>
71 /// Set individual Tool launching parameters and propagate the delegate further
72 /// </summary>
73 /// <param name="tool"></param>
74 /// <param name="args"></param>
75 /// <remarks>
76 /// <list>
77 /// <item><term>Arguments </term><description> will be concatenated</description></item>
78 /// <item><term>Working directory </term><description> B overrides the one from A but not when B doesn't have one</description></item>
79 /// <item><term>Environmnent variables </term><description> will be merged</description></item>
80 /// <item><term>TimeOut </term><description> will be maxed</description></item>
81 /// <item><term>LogOutput </term><description> is OR-ed</description></item>
82 /// <item><term>LogInvocation </term><description> is OR-ed</description></item>
83 /// <item><term>Logger / ExitHandler </term><description>A + B is invoked</description></item>
84 /// <item><term>Input </term><description>A + B is invoked</description></item>
85 /// <item><term>Encodings </term><description> B overrides the one from A but not when B doesn't have one</description></item>
86 /// </list>
87 /// </remarks>
88 public static ToolEx With(this ToolEx tool, ToolExArguments args)
89 => new PropagateToolExExecution(tool, args).Execute;
90
91 /// <summary>
92 /// Set individual Tool launching parameters and propagate the delegate further
93 /// </summary>
94 /// <param name="tool"></param>
95 /// <param name="args"></param>
96 /// <remarks>
97 /// <list>
98 /// <item><term>Arguments </term><description> will be concatenated</description></item>
99 /// <item><term>Working directory </term><description> B overrides the one from A but not when B doesn't have one</description></item>
100 /// <item><term>Environmnent variables </term><description> will be merged</description></item>
101 /// <item><term>TimeOut </term><description> will be maxed</description></item>
102 /// <item><term>LogOutput </term><description> is OR-ed</description></item>
103 /// <item><term>LogInvocation </term><description> is OR-ed</description></item>
104 /// <item><term>Logger / ExitHandler </term><description>A + B is invoked</description></item>
105 /// <item><term>Input </term><description> Used from ToolEx arguments</description></item>
106 /// <item><term>Encodings </term><description> Used from ToolEx arguments</description></item>
107 /// </list>
108 /// </remarks>
109 public static ToolEx With(this ToolEx tool, ToolArguments args)
110 => new PropagateToolExExecution(tool, new(args)).Execute;
111
112 /// <summary>
113 /// Set individual Tool launching parameters and propagate the delegate further
114 /// </summary>
115 /// <param name="tool"></param>
116 /// <param name="arguments"></param>
117 /// <param name="workingDirectory"></param>
118 /// <param name="environmentVariables"></param>
119 /// <param name="timeout"></param>
120 /// <param name="logOutput"></param>
121 /// <param name="logInvocation"></param>
122 /// <param name="logger"></param>
123 /// <param name="exitHandler"></param>
124 /// <remarks>
125 /// <list>
126 /// <item><term>Arguments </term><description> will be concatenated</description></item>
127 /// <item><term>Working directory </term><description> B overrides the one from A but not when B doesn't have one</description></item>
128 /// <item><term>Environmnent variables </term><description> will be merged</description></item>
129 /// <item><term>TimeOut </term><description> will be maxed</description></item>
130 /// <item><term>LogOutput </term><description> is OR-ed</description></item>
131 /// <item><term>LogInvocation </term><description> is OR-ed</description></item>
132 /// <item><term>Logger / ExitHandler </term><description>A + B is invoked</description></item>
133 /// </list>
134 /// </remarks>
135 public static Tool With(
136 this Tool tool,
137 ArgumentStringHandler arguments = default,
138 string? workingDirectory = null,
139 IReadOnlyDictionary<string, string>? environmentVariables = null,
140 int? timeout = null,
141 bool? logOutput = null,
142 bool? logInvocation = null,
143 Action<OutputType, string>? logger = null,
144 Action<IProcess>? exitHandler = null
145 ) => tool.With(new ToolArguments(
146 arguments.ToStringAndClear(),
147 workingDirectory,
148 environmentVariables,
149 timeout,
150 logOutput,
151 logInvocation,
152 logger,
153 exitHandler
154 ));
155
156 /// <summary>
157 /// Set individual Tool launching parameters and propagate the delegate further
158 /// </summary>
159 /// <param name="tool"></param>
160 /// <param name="arguments"></param>
161 /// <param name="workingDirectory"></param>
162 /// <param name="environmentVariables"></param>
163 /// <param name="timeout"></param>
164 /// <param name="logOutput"></param>
165 /// <param name="logInvocation"></param>
166 /// <param name="logger"></param>
167 /// <param name="exitHandler"></param>
168 /// <param name="input">Handle standard input stream after process creation</param>
169 /// <param name="standardOutputEncoding">Encoding for standard output. Default is UTF8 (with BOM)</param>
170 /// <param name="standardInputEncoding">Encoding for standard input. Default is UTF8 (without BOM)</param>
171 /// <remarks>
172 /// <list>
173 /// <item><term>Arguments </term><description> will be concatenated</description></item>
174 /// <item><term>Working directory </term><description> B overrides the one from A but not when B doesn't have one</description></item>
175 /// <item><term>Environmnent variables </term><description> will be merged</description></item>
176 /// <item><term>TimeOut </term><description> will be maxed</description></item>
177 /// <item><term>LogOutput </term><description> is OR-ed</description></item>
178 /// <item><term>LogInvocation </term><description> is OR-ed</description></item>
179 /// <item><term>Logger / ExitHandler </term><description>A + B is invoked</description></item>
180 /// <item><term>Input </term><description>A + B is invoked</description></item>
181 /// <item><term>Encodings </term><description> B overrides the one from A but not when B doesn't have one</description></item>
182 /// </list>
183 /// </remarks>
184 public static ToolEx With(
185 this ToolEx tool,
186 ArgumentStringHandler arguments = default,
187 string? workingDirectory = null,
188 IReadOnlyDictionary<string, string>? environmentVariables = null,
189 int? timeout = null,
190 bool? logOutput = null,
191 bool? logInvocation = null,
192 Action<OutputType, string>? logger = null,
193 Action<IProcess>? exitHandler = null,
194 Action<StreamWriter>? input = null,
195 Encoding? standardOutputEncoding = null,
196 Encoding? standardInputEncoding = null
197 ) => tool.With(new ToolExArguments(
198 new(
199 arguments.ToStringAndClear(),
200 workingDirectory,
201 environmentVariables,
202 timeout,
203 logOutput,
204 logInvocation,
205 logger,
206 exitHandler
207 ),
208 input,
209 standardOutputEncoding,
210 standardInputEncoding
211 ));
212
213 /// <summary>
214 /// Mark app output Debug/Info/Warning/Error based on its content rather than the stream
215 /// they were added to.
216 /// </summary>
217 /// <param name="filter"></param>
218 /// <param name="normalOutputLogger"></param>
219 public static ToolArguments SemanticLogging(Func<string, bool>? filter = null, Action<OutputType, string>? normalOutputLogger = null)
220 => new(Logger: (t, l) =>
221 {
222 if (!(filter?.Invoke(l) ?? true)) return;
223
224 if (l.ContainsAnyOrdinalIgnoreCase("success", "complete", "ready", "start", "***"))
225 {
226 Log.Information(l);
227 }
228 else if (l.ContainsOrdinalIgnoreCase("warning"))
229 {
230 Log.Warning(l);
231 }
232 else if (l.ContainsAnyOrdinalIgnoreCase("error", "fail"))
233 {
234 Log.Error(l);
235 }
236 else
237 {
238 if (normalOutputLogger != null)
239 normalOutputLogger(t, l);
240 else
241 {
242 Log.Debug(l);
243 }
244 }
245 });
246
247 /// <summary>
248 /// Mark app output Debug/Info/Warning/Error based on its content rather than the stream
249 /// they were added to.
250 /// </summary>
251 /// <param name="tool"></param>
252 /// <param name="filter"></param>
253 /// <param name="normalOutputLogger"></param>
254 public static Tool WithSemanticLogging(this Tool tool, Func<string, bool>? filter = null, Action<OutputType, string>? normalOutputLogger = null)
255 => tool.With(SemanticLogging(filter, normalOutputLogger));
256
257 /// <summary>
258 /// Mark app output Debug/Info/Warning/Error based on its content rather than the stream
259 /// they were added to.
260 /// </summary>
261 /// <param name="tool"></param>
262 /// <param name="filter"></param>
263 /// <param name="normalOutputLogger"></param>
264 public static ToolEx WithSemanticLogging(this ToolEx tool, Func<string, bool>? filter = null, Action<OutputType, string>? normalOutputLogger = null)
265 => tool.With(SemanticLogging(filter, normalOutputLogger));
266
267 /// <summary>
268 /// ToolArguments for priming environment variables
269 /// </summary>
270 public static ToolArguments CurrentEnvironment => new(EnvironmentVariables: EnvironmentInfo.Variables);
271
272 /// <summary>
273 /// A more comfortable passing of environment variables. This will also pass on parent environment
274 /// </summary>
275 public static ToolArguments EnvVar(string key, object value, bool includeParentEnvironment = true)
276 {
277 var result = includeParentEnvironment
278 ? EnvironmentInfo.Variables.ToDictionary()
279 : new();
280
281 result[key] = value.ToString();
282 return new(EnvironmentVariables: result);
283 }
284
285 /// <summary>
286 /// A more comfortable passing of environment variables. This will also pass on parent environment
287 /// </summary>
288 public static ToolArguments EnvVars(bool includeParentEnvironment, params (string key, object value)[] items)
289 {
290 var parent = includeParentEnvironment
291 ? EnvironmentInfo.Variables.ToDictionary()
292 : null;
293 var itemsDict = items.ToDictionary(i => i.key, i => i.value!.ToString()!);
294 return new(EnvironmentVariables: parent.Merge(itemsDict));
295 }
296
297 /// <summary>
298 /// A more comfortable passing of environment variables. This will also pass on parent environment
299 /// </summary>
300 public static ToolArguments EnvVars(params (string key, object value)[] items) => EnvVars(true, items);
301
302 /// <summary>
303 /// A more comfortable passing of environment variables. This will also pass on parent environment
304 /// </summary>
305 public static Tool WithEnvVar(this Tool tool, string key, object value, bool includeParentEnvironment = true)
306 => tool.With(EnvVar(key, value, includeParentEnvironment));
307
308 /// <summary>
309 /// A more comfortable passing of environment variables. This will also pass on parent environment
310 /// </summary>
311 public static Tool WithEnvVars(this Tool tool, bool includeParentEnvironment, params (string key, object value)[] items)
312 => tool.With(EnvVars(includeParentEnvironment, items));
313
314 /// <summary>
315 /// A more comfortable passing of environment variables. This will also pass on parent environment
316 /// </summary>
317 public static Tool WithEnvVars(this Tool tool, params (string key, object value)[] items)
318 => tool.With(EnvVars(items));
319
320 /// <summary>
321 /// Add an input path to this tool's PATH list. It won't be added if input path is already in there.
322 /// </summary>
323 public static Tool WithPathVar(this Tool tool, AbsolutePath path)
324 => tool.WithEnvVar(
325 "PATH",
326 EnvironmentInfo.Paths.Union([ path.ToString() ]).JoinSemicolon()
327 );
328
329 /// <summary>
330 /// A more comfortable passing of environment variables. This will also pass on parent environment
331 /// </summary>
332 public static ToolEx WithEnvVar(this ToolEx tool, string key, object value, bool includeParentEnvironment = true)
333 => tool.With(EnvVar(key, value, includeParentEnvironment));
334
335 /// <summary>
336 /// A more comfortable passing of environment variables. This will also pass on parent environment
337 /// </summary>
338 public static ToolEx WithEnvVars(this ToolEx tool, params (string key, object value)[] items)
339 => tool.With(EnvVars(items));
340
341 /// <summary>
342 /// A more comfortable passing of environment variables. This will also pass on parent environment
343 /// </summary>
344 public static ToolEx WithEnvVars(this ToolEx tool, bool includeParentEnvironment, params (string key, object value)[] items)
345 => tool.With(EnvVars(includeParentEnvironment, items));
346
347 /// <summary>
348 /// Add an input path to this tool's PATH list. It won't be added if input path is already in there.
349 /// </summary>
350 public static ToolEx WithPathVar(this ToolEx tool, AbsolutePath path)
351 => tool.WithEnvVar(
352 "PATH",
353 EnvironmentInfo.Paths.Union([ path.ToString() ]).JoinSemicolon()
354 );
355
356 /// <summary>
357 /// Removes ANSI escape sequences from the output of a Tool (remove color data for example)
358 /// </summary>
359 public static IEnumerable<Output> RemoveAnsiEscape(this IEnumerable<Output> toolOutput)
360 => toolOutput.Select(l => new Output
361 {
362 Type = l.Type,
363 Text = l.Text.ReplaceRegex("\x1b\\[[0-9;]*[mK]", m => "")
364 });
365
366 /// <summary>
367 /// Pipe the results of a tool into the standard input of the next tool. This is not exactly the same as real
368 /// command line piping, the previous process needs to be finished first to pipe its output into the next one.
369 /// This however gives the opportunity to transform / filter the output of previous tool with regular LINQ
370 /// before passing it to the next one.
371 /// </summary>
372 /// <param name="previous">The output of a previous program</param>
373 /// <param name="next">Initial tool delegate of the next program</param>
374 /// <param name="pipeError">Also pipe standard-error into next program</param>
375 /// <param name="close">
376 /// If this is true, close the input stream after all the lines have been written. This is set to true by
377 /// default for ease of usage, as most of the time a program's output is the only thing needed to be passed to
378 /// another program. However if false don't forget to queue closing the input stream with CloseInput.
379 /// </param>
380 /// <returns>A composite ToolEx delegate</returns>
381 public static ToolEx Pipe(this IEnumerable<Output> previous, ToolEx next, bool pipeError = false, bool close = true)
382 => next.With(input: s =>
383 {
384 foreach (var line in previous)
385 {
386 if (line.Type == OutputType.Std || pipeError)
387 s.WriteLine(line.Text);
388 }
389 if (close) s.Close();
390 });
391
392 /// <summary>
393 /// Provide lines for standard input once the program is run. If the target program waits until end-of-stream
394 /// queue closing the input stream with CloseInput.
395 /// </summary>
396 /// <param name="tool"></param>
397 /// <param name="lines"></param>
398 public static ToolEx WithInput(this ToolEx tool, IEnumerable<string> lines)
399 => tool.With(input: s =>
400 {
401 foreach (var line in lines)
402 s.WriteLine(line);
403 });
404
405 /// <summary>
406 /// Provide a single line for standard input once the program is run.
407 /// </summary>
408 /// <param name="tool"></param>
409 /// <param name="line"></param>
410 public static ToolEx WithInput(this ToolEx tool, string line)
411 => tool.With(input: s => s.WriteLine(line));
412
413 /// <summary>
414 /// Explicitly close the standard input after other inputs have been queued. Some programs may freeze without
415 /// this step.
416 /// </summary>
417 /// <param name="tool"></param>
418 public static ToolEx CloseInput(this ToolEx tool) => tool.With(input: s => s.Close());
419
420 /// <summary>
421 /// Attempt to update PATH of this process from user's environment variables
422 /// </summary>
423 public static void UpdatePathEnvVar()
424 {
425 if (!EnvironmentInfo.IsWin) return;
426 var processPaths = EnvironmentInfo.Paths;
427 var userPaths = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.User)!.Split(';');
428 var machinePaths = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine)!.Split(';');
429
430 var result = processPaths.Union(userPaths).Union(machinePaths).JoinSemicolon();
431 Environment.SetEnvironmentVariable("PATH", result);
432 }
433
434 /// <summary>
435 /// Get a tool which should be in PATH, and provide an optional way to set it up automatically if it wasn't
436 /// </summary>
437 /// <returns>The Tool or an error if it wasn't in PATH and the setup had failed</returns>
438 public static ValueOrError<Tool> Use(string tool, Action? setup = null)
439 => ErrorHandling.TryGet(() => ToolResolver.GetPathTool(tool))
440 .Else(setup != null, () =>
441 {
442 Log.Warning($"{tool} was not installed, but it's OK we're installing it now.");
443 setup!();
445 return ToolResolver.GetPathTool(tool);
446 });
447
448 /// <summary>
449 /// Try a different setup method for a Tool which may failed its installation
450 /// </summary>
451 /// <param name="result">Result of the previous attempt</param>
452 /// <param name="condition">Only attempt this method of setup when condition is met</param>
453 /// <param name="tool">The name of the tool</param>
454 /// <param name="setup">Setup the tool for the caller</param>
455 /// <returns>The Tool or an error if it this or previous setup attempts have failed</returns>
456 public static ValueOrError<Tool> ElseTrySetup(this ValueOrError<Tool> result, bool condition, string tool, Action setup)
457 => result.Else(condition, () =>
458 {
459 setup();
461 return ToolResolver.GetPathTool(tool);
462 });
463
464 /// <summary>
465 /// Try a different setup method for a Tool which may failed its installation
466 /// </summary>
467 /// <param name="result">Result of the previous attempt</param>
468 /// <param name="tool">The name of the tool</param>
469 /// <param name="setup">Setup the tool for the caller</param>
470 /// <returns>The Tool or an error if it this or previous setup attempts have failed</returns>
471 public static ValueOrError<Tool> ElseTrySetup(this ValueOrError<Tool> result, string tool, Action setup)
472 => result.ElseTrySetup(true, tool, setup);
473}
static Attempt Else(this Attempt self, Action action, Action< Exception >? onFailure=null)
If input attempt is an error then attempt to execute another input action (which may also fail)
static Tool WithEnvVars(this Tool tool, params(string key, object value)[] items)
A more comfortable passing of environment variables. This will also pass on parent environment.
static ToolEx WithSemanticLogging(this ToolEx tool, Func< string, bool >? filter=null, Action< OutputType, string >? normalOutputLogger=null)
Mark app output Debug/Info/Warning/Error based on its content rather than the stream they were added ...
static ToolArguments SemanticLogging(Func< string, bool >? filter=null, Action< OutputType, string >? normalOutputLogger=null)
Mark app output Debug/Info/Warning/Error based on its content rather than the stream they were added ...
static void UpdatePathEnvVar()
Attempt to update PATH of this process from user's environment variables.
Definition ToolCola.cs:423
static ToolEx WithEnvVar(this ToolEx tool, string key, object value, bool includeParentEnvironment=true)
A more comfortable passing of environment variables. This will also pass on parent environment.
static IEnumerable< Output > RemoveAnsiEscape(this IEnumerable< Output > toolOutput)
Removes ANSI escape sequences from the output of a Tool (remove color data for example)
static Tool With(this Tool tool, ArgumentStringHandler arguments=default, string? workingDirectory=null, IReadOnlyDictionary< string, string >? environmentVariables=null, int? timeout=null, bool? logOutput=null, bool? logInvocation=null, Action< OutputType, string >? logger=null, Action< IProcess >? exitHandler=null)
Set individual Tool launching parameters and propagate the delegate further.
static ToolArguments EnvVar(string key, object value, bool includeParentEnvironment=true)
A more comfortable passing of environment variables. This will also pass on parent environment.
Definition ToolCola.cs:275
static ToolEx With(this ToolEx tool, ToolArguments args)
Set individual Tool launching parameters and propagate the delegate further.
static ToolEx With(this ToolEx tool, ToolExArguments args)
Set individual Tool launching parameters and propagate the delegate further.
static ToolEx With(this ToolEx tool, ArgumentStringHandler arguments=default, string? workingDirectory=null, IReadOnlyDictionary< string, string >? environmentVariables=null, int? timeout=null, bool? logOutput=null, bool? logInvocation=null, Action< OutputType, string >? logger=null, Action< IProcess >? exitHandler=null, Action< StreamWriter >? input=null, Encoding? standardOutputEncoding=null, Encoding? standardInputEncoding=null)
Set individual Tool launching parameters and propagate the delegate further.
static ValueOrError< Tool > ElseTrySetup(this ValueOrError< Tool > result, bool condition, string tool, Action setup)
Try a different setup method for a Tool which may failed its installation.
static ToolEx WithInput(this ToolEx tool, IEnumerable< string > lines)
Provide lines for standard input once the program is run. If the target program waits until end-of-st...
static ? IReadOnlyCollection< Output > ExecuteWith(this ToolEx tool, ToolExArguments args)
Execute a tool with standard input with the arguments provided by the input record.
static ToolEx WithPathVar(this ToolEx tool, AbsolutePath path)
Add an input path to this tool's PATH list. It won't be added if input path is already in there.
static Tool WithEnvVars(this Tool tool, bool includeParentEnvironment, params(string key, object value)[] items)
A more comfortable passing of environment variables. This will also pass on parent environment.
static IReadOnlyCollection< Output > ExecuteWith(this Tool tool, ToolArguments args)
Execute a tool with the arguments provided by the input record.
static ToolArguments CurrentEnvironment
ToolArguments for priming environment variables.
Definition ToolCola.cs:270
static ToolEx WithEnvVars(this ToolEx tool, bool includeParentEnvironment, params(string key, object value)[] items)
A more comfortable passing of environment variables. This will also pass on parent environment.
static ToolArguments EnvVars(bool includeParentEnvironment, params(string key, object value)[] items)
A more comfortable passing of environment variables. This will also pass on parent environment.
Definition ToolCola.cs:288
static ToolEx WithInput(this ToolEx tool, string line)
Provide a single line for standard input once the program is run.
static ValueOrError< Tool > Use(string tool, Action? setup=null)
Get a tool which should be in PATH, and provide an optional way to set it up automatically if it wasn...
static Tool WithEnvVar(this Tool tool, string key, object value, bool includeParentEnvironment=true)
A more comfortable passing of environment variables. This will also pass on parent environment.
static ToolEx WithEnvVars(this ToolEx tool, params(string key, object value)[] items)
A more comfortable passing of environment variables. This will also pass on parent environment.
static Tool With(this Tool tool, ToolArguments args)
Set individual Tool launching parameters and propagate the delegate further.
static ToolArguments EnvVars(params(string key, object value)[] items)
A more comfortable passing of environment variables. This will also pass on parent environment.
static ToolEx Pipe(this IEnumerable< Output > previous, ToolEx next, bool pipeError=false, bool close=true)
Pipe the results of a tool into the standard input of the next tool. This is not exactly the same as ...
static Tool WithPathVar(this Tool tool, AbsolutePath path)
Add an input path to this tool's PATH list. It won't be added if input path is already in there.
static Tool WithSemanticLogging(this Tool tool, Func< string, bool >? filter=null, Action< OutputType, string >? normalOutputLogger=null)
Mark app output Debug/Info/Warning/Error based on its content rather than the stream they were added ...
static ToolEx CloseInput(this ToolEx tool)
Explicitly close the standard input after other inputs have been queued. Some programs may freeze wit...
static ValueOrError< Tool > ElseTrySetup(this ValueOrError< Tool > result, string tool, Action setup)
Try a different setup method for a Tool which may failed its installation.
record class PropagateToolExExecution(ToolEx Target, ToolExArguments? PropagateArguments=null)
Propagated ToolEx delegate provider for launch parameter composition.
Definition ToolEx.cs:124
delegate? IReadOnlyCollection< Output > ToolEx(ArgumentStringHandler arguments=default, string? workingDirectory=null, IReadOnlyDictionary< string, string >? environmentVariables=null, int? timeout=null, bool? logOutput=null, bool? logInvocation=null, Action< OutputType, string >? logger=null, Action< IProcess >? exitHandler=null, Action< StreamWriter >? input=null, Encoding? standardOutputEncoding=null, Encoding? standardInputEncoding=null)
Extended copy of Tool delegate of Nuke.
record class ToolArguments(string? Arguments=null, string? WorkingDirectory=null, IReadOnlyDictionary< string, string >? EnvironmentVariables=null, int? Timeout=null, bool? LogOutput=null, bool? LogInvocation=null, Action< OutputType, string >? Logger=null, Action< IProcess >? ExitHandler=null)
A record listing Tool delegate parameters and provides a way to meaningfully merge multiple together.
record class ToolExArguments(ToolArguments ToolArgs, Action< StreamWriter >? Input=null, Encoding? StandardOutputEncoding=null, Encoding? StandardInputEncoding=null)
A record listing Tool and ToolEx delegate parameters and provides a way to meaningfully merge multipl...
Definition ToolEx.cs:39
record class PropagateToolExecution(Tool Target, ToolArguments? PropagateArguments=null)
Propagated Tool delegate provider for launch parameter composition.