static void Main(string[] args) { WrapServices.TryRegisterService<IEnvironment>(() => new CurrentDirectoryEnvironment()); WrapServices.TryRegisterService<IPackageManager>(() => new PackageManager()); var commands = ReadCommands(WrapServices.GetService<IEnvironment>()); var repo = new CommandRepository(commands); WrapServices.TryRegisterService<ICommandRepository>(() => repo); var processor = new CommandLineProcessor(repo); var backedupConsoleColor = System.Console.ForegroundColor; foreach (var commandResult in processor.Execute(args).Where(x => x != null)) { try { if (!commandResult.Success) System.Console.ForegroundColor = ConsoleColor.Red; System.Console.WriteLine(commandResult); } finally { System.Console.ForegroundColor = backedupConsoleColor; } } System.Console.ReadLine(); }
public override bool Execute() { if (Debug) Debugger.Launch(); _success = true; var commandProcessor = new CommandLineProcessor(new CommandRepository(ReadCommands(Services.Services.GetService<IEnvironment>()))); foreach (var cmd in commandProcessor.Execute(new[] { Noun, Verb }.Concat(GetArguments()).ToList())) ProcessOutput(cmd); return _success; }
static IEnumerable<ICommandOutput> AllOutputs(CommandLineProcessor processor, string[] args) { return processor.Execute(args); //var eventListener = Services.Services.GetService<ITaskManager>().GetListener(); //return Wrap(processor.Execute(args), eventListener).Merge(eventListener.Start().Select(x => ProgressMessage(x))); }