namespace QRScript.Console; [Command("run", Description = "Run a Glyph program.")] public class RunCommand : ICommand { [CommandParameter(0, Name = "file", Description = "Path to the Glyph source file.")] public string FilePath { get; set; } [CommandOption("input", 'i', Description = "Path to optional input file.")] public string InputPath { get; set; } [CommandOption("binary", 'b', Description = "Run binary file")] public bool Binary { get; set; } [CommandOption("verbose", 'v', Description = "Enable verbose output.")] public bool Verbose { get; set; } public async ValueTask ExecuteAsync(IConsole console) { var lines = new string[] { }; var fileInfo = new FileInfo(FilePath); var file = fileInfo.FullName; var dir = Path.GetDirectoryName(FilePath); var path = Path.Combine(dir, file); if (!System.IO.File.Exists(path)) { await console.Error.WriteLineAsync($"Error: File not found: {file}"); return; } if (Binary) { // TODO: Implement binary file execution await console.Error.WriteLineAsync($"Error: Binary file execution not implemented"); return; } lines = await System.IO.File.ReadAllLinesAsync(path); var source = lines.JoinLines(); if (!string.IsNullOrEmpty(InputPath)) { // You could inject input to the interpreter here string input = await File.ReadAllTextAsync(InputPath); // TODO: Attach to interpreter input stream } if (Verbose) { await console.Output.WriteLineAsync($"Executing: {path}"); if (source.ExceedsLengthLimit(1259)) await console.Output.WriteAsync($"Warning: source code exceeds {1259:n} characters."); } Runner.Interpret(lines); } }