- ExecutableResolver: catalog executables resolve to absolute paths in System32/Windows (and
the winget alias), so CreateProcess never searches the per-user, user-writable app folder —
a planted reg.exe/powershell.exe there would otherwise run elevated. Launch-mode commands now
pin their working directory too.
- OutputDecoder: stdout/stderr are read as raw bytes and decoded per line (UTF-16LE when the
stream is UTF-16, else strict UTF-8 with an OEM-code-page fallback). sfc/wsl output and every
native tool on Vietnamese/Japanese/Chinese Windows used to show as mojibake. Lone \r (progress
updates) still breaks lines.
- ProcessJob: captured commands join a kill-on-close job object, so closing or crashing the app
can no longer leave a half-finished command running.
- ArgumentTokens ({SystemDrive}, {SystemRoot}, {UserProfile}) filled from SystemPaths, which reads
the kernel-reported system directory, known folders and HKLM — never %SystemRoot%-style
variables a standard user can redefine. The command preview shows the expanded values.
- Exit code 3010 always flags a restart; Launch commands honour RestartPolicy.Always; output is
only captured (bounded) when a restart regex needs it. ExecutionResult.OutputLines is gone
(nothing read it, and it held the entire output in memory).
- RunCommandUseCase always completes the output channel and maps cancellation, so a failing run
can no longer leave the console waiting forever.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
982 B
C#
29 lines
982 B
C#
namespace CommandForge.Domain;
|
|
|
|
/// <summary>
|
|
/// The outcome of running a command.
|
|
/// </summary>
|
|
public sealed record ExecutionResult
|
|
{
|
|
/// <summary>Exit code signalling that a restart is required (ERROR_SUCCESS_REBOOT_REQUIRED).</summary>
|
|
public const int RebootRequiredExitCode = 3010;
|
|
|
|
/// <summary>Process exit code.</summary>
|
|
public required int ExitCode { get; init; }
|
|
|
|
/// <summary>Whether the command is considered successful.</summary>
|
|
public required bool Success { get; init; }
|
|
|
|
/// <summary>Wall-clock duration of the run.</summary>
|
|
public required TimeSpan Duration { get; init; }
|
|
|
|
/// <summary>
|
|
/// Whether a system restart is required to finish (exit code 3010, a restart-always command, or
|
|
/// an output-regex match).
|
|
/// </summary>
|
|
public bool RequiresRestart { get; init; }
|
|
|
|
/// <summary>Whether the run was cancelled by the user (process tree killed).</summary>
|
|
public bool Cancelled { get; init; }
|
|
}
|