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 static int Main(string[] args)
        {
            if (args == null || args.Length == 0)
            {
                Console.WriteLine("No command was entered. Type 'get-help' to get a list of supported commands.");
            }
            Services.Services.RegisterService<RuntimeAssemblyResolver>(new RuntimeAssemblyResolver());
            Services.Services.TryRegisterService<IFileSystem>(() => LocalFileSystem.Instance);
            Services.Services.TryRegisterService<IConfigurationManager>(() => new ConfigurationManager(Services.Services.GetService<IFileSystem>().GetDirectory(InstallationPaths.ConfigurationDirectory)));
            Services.Services.TryRegisterService<IEnvironment>(() => new CurrentDirectoryEnvironment());

            Services.Services.TryRegisterService<IPackageResolver>(() => new ExhaustiveResolver());
            Services.Services.TryRegisterService<IPackageExporter>(() => new DefaultPackageExporter());
            Services.Services.TryRegisterService<IPackageDeployer>(() => new DefaultPackageDeployer());
            Services.Services.TryRegisterService<IPackageManager>(() => new DefaultPackageManager(
                Services.Services.GetService<IPackageDeployer>(),
                Services.Services.GetService<IPackageResolver>(),
                Services.Services.GetService<IPackageExporter>()
                ));

            Services.Services.RegisterService<ITaskManager>(new TaskManager());

            var commands = Services.Services.GetService<IEnvironment>().Commands();
            var repo = new CommandRepository(commands);

            Services.Services.TryRegisterService<ICommandRepository>(() => repo);
            var processor = new CommandLineProcessor(repo);
            var backedupConsoleColor = Console.ForegroundColor;
            var returnCode = 0;
            foreach (var commandOutput in AllOutputs(processor, args).Where(x => x != null))
            {
                try
                {
                    if (HiddenVerboseOutput(args, commandOutput))
                        continue;
                    SetCommandColor(commandOutput.Type);
                    RenderOutput(commandOutput);
                    if (commandOutput.Type == CommandResultType.Error)
                    {
                        returnCode = -1;
                    }
                }
                finally
                {
                    Console.ForegroundColor = backedupConsoleColor;
                }
            }
            if (Debugger.IsAttached)
            {
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
            }
            return returnCode;
        }
Esempio n. 3
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. 4
0
        public static int Main(string[] args)
        {
            WrapServices.TryRegisterService<IFileSystem>(() => LocalFileSystem.Instance);
            WrapServices.TryRegisterService<IConfigurationManager>(() => new ConfigurationManager(WrapServices.GetService<IFileSystem>().GetDirectory(InstallationPaths.ConfigurationDirectory)));
            WrapServices.TryRegisterService<IEnvironment>(() => new CurrentDirectoryEnvironment());

            WrapServices.TryRegisterService<IPackageManager>(() => new PackageManager());
            WrapServices.RegisterService<RuntimeAssemblyResolver>(new RuntimeAssemblyResolver());
            WrapServices.RegisterService<ITaskManager>(new TaskManager());

            var commands = ReadCommands(WrapServices.GetService<IEnvironment>());
            var repo = new CommandRepository(commands);

            WrapServices.TryRegisterService<ICommandRepository>(() => repo);
            var processor = new CommandLineProcessor(repo);
            var backedupConsoleColor = Console.ForegroundColor;
            var returnCode = 0;
            foreach (var commandOutput in AllOutputs(processor, args).Where(x => x != null))
            {
                try
                {
                    if (HiddenVerboseOutput(args, commandOutput))
                        continue;
                    SetCommandColor(commandOutput.Type);
                    if (!commandOutput.Success)
                    {
                        returnCode = -1;
                    }
                    RenderOutput(commandOutput);
                }
                finally
                {
                    Console.ForegroundColor = backedupConsoleColor;
                }
            }
            if (Debugger.IsAttached)
            {
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
            }
            return returnCode;
        }
Esempio n. 5
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)));
 }