public CommandEmission(ICommandSpec CommandSpec, Option <FilePath> OutputPath) { this.CommandSpec = CommandSpec; this.OutputPath = OutputPath; this.Description = Succeeded ? AppMessage.Inform($"Emitted {CommandSpec.SpecName}") : OutputPath.Message; }
public static Task <CommandProcessExecutionLog> Invoke(FilePath ExecutablePath, string args, string workdir = null) { var proc = new Process { StartInfo = new ProcessStartInfo { FileName = ExecutablePath, Arguments = args, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, WorkingDirectory = workdir ?? Environment.CurrentDirectory }, EnableRaisingEvents = true, }; var result = new CommandProcessExecutionLog(); proc.OutputDataReceived += (sender, e) => { if (isNotBlank(e.Data)) { result.StatusMessages.Add(e.Data); SystemConsole.Get().Write(AppMessage.Inform(e.Data)); } }; proc.ErrorDataReceived += (sender, e) => { if (isNotBlank(e.Data)) { result.ErrorMessages.Add(e.Data); SystemConsole.Get().Write(AppMessage.Error(e.Data)); } }; proc.Start(); proc.BeginOutputReadLine(); proc.BeginErrorReadLine(); return(Task.Run(() => { proc.WaitForExit(); result.ExitCode = proc.ExitCode; proc.Dispose(); return result; })); }
public static FileWriteResult Success(FilePath DstPath, IAppMessage Message = null) => new FileWriteResult(DstPath, Message ?? AppMessage.Inform($"The {DstPath} file was successfully written"));
static IAppMessage ControllerStarting() => AppMessage.Inform("Starting controller and subject orchestrations", new { });
public IAppMessage ToMessage() => AppMessage.Inform( $"{nameof(TotalSubmissions)}: @{nameof(TotalSubmissions)}, " + $"{nameof(TotalDispatches)}: @{nameof(TotalDispatches)}, " + $"{nameof(TotalCompletions)}: @{nameof(TotalCompletions)} " + $"{nameof(Duration)}: @{nameof(Duration)}s", this);
/// <summary> /// Defines a status message /// </summary> /// <param name="text">The message text</param> /// <param name="callerFile">The file from which the call was made</param> /// <param name="callerName">The name of the invoking member</param> /// <returns></returns> public static IAppMessage inform(string text, [CallerFilePath] string callerFile = null, [CallerMemberName] string callerName = null) => AppMessage.Inform(text, callerFile, callerName);
/// <summary> /// Defines a correlated status message with typed content /// </summary> /// <typeparam name="C">The content type</typeparam> /// <param name="CT">The correlation value</param> /// <param name="template">A content-bound template string</param> /// <param name="content">The typed content</param> /// <param name="callerFile">The file from which the call was made</param> /// <param name="callerName">The name of the invoking member</param> /// <returns></returns> public static IAppMessage inform <C>(CorrelationToken CT, string template, C content, [CallerFilePath] string callerFile = null, [CallerMemberName] string callerName = null) => AppMessage.Inform(CT, template, content, callerFile, callerName);
public IAppMessage ToMessage() => AppMessage.Inform( "Pending:@PendingTaskCount Executing:@ExecutingTaskCount Executed:@ExecutedTaskCount Spinners:@SpinnerCount Revolutions:@RevolutionCount Last Submitted: @LastSubmissionCount", this);
public static IAppMessage Stopped() => AppMessage.Inform("Agent execution stopped");
public static IAppMessage Stopping() => AppMessage.Inform("Stopping agent");
public static IAppMessage WaitingForTasks(int Count, int Timeout) => AppMessage.Inform("Waiting a maximum of @Timeout ms for @Count currently executing tasks to finish", new { Count, Timeout });
public static IAppMessage TaskGroupExecutionCancelled(string GroupName) => AppMessage.Inform("The @GroupName task group was cancelled", new { GroupName });
protected static IAppMessage Describe <C>(string template, C content, [CallerFilePath] string callerFile = null, [CallerMemberName] string callerName = null) => AppMessage.Inform(template, content, callerFile, callerName);