Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        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;
        }
Esempio n. 3
0
 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)));
 }