using CommandForge.Domain;
namespace CommandForge.Application;
///
/// Builds the exact command line shown to the user before running (transparency —
/// see docs/Security.md §1). The executor passes the same argument string to the process.
///
public static class CommandPreview
{
/// Returns executable args with path tokens left as placeholders.
public static string Build(CommandDefinition command)
=> Build(command, new Dictionary());
/// Returns executable args with replaced by .
public static string Build(CommandDefinition command, IReadOnlyDictionary tokens)
{
ArgumentNullException.ThrowIfNull(command);
ArgumentNullException.ThrowIfNull(tokens);
var args = ArgumentTokens.Expand(command.ArgsTemplate, tokens).Trim();
return args.Length == 0 ? command.Executable : $"{command.Executable} {args}";
}
}