示例#1
0
        public static int Main(string[] args)
        {
            Directory.SetCurrentDirectory(AssemblyDirectory);
            LoggingInitializer.ConfigureLogging(args);
            Presenter.ShowApplicationHeading(Logger, Assembly.GetEntryAssembly().GetName().Version, args);
            var clientFactory = CreateClientFactory();
            var runner        = CreateRunner(clientFactory);
            var arguments     = runner.ParseArguments(args);

            if (arguments != null)
            {
                if (arguments.HasArgumentLabeled("on:"))
                {
                    var hostname = arguments.FindValueFromLabel("on:").Value;
                    Presenter.ShowMessage($"on node: {hostname}", Logger);
                    clientFactory.Hostname = hostname;
                }
                var returnValue = runner.RunProgram(arguments);
                Logger.Debug("Finishing cafe run");
                return(returnValue);
            }
            else
            {
                Presenter.ShowError("No options match the supplied arguments. Run cafe help to view all options",
                                    Logger);
                return(-2);
            }
        }
示例#2
0
        public static int Main(string[] args)
        {
            Directory.SetCurrentDirectory(AssemblyDirectory);
            LoggingInitializer.ConfigureLogging(args);
            const string application = "cafe.Updater";

            var processExecutor = new ProcessExecutor(() => new ProcessBoundary());

            IWin32Service ServiceFactory() => new CafeUpdaterWindowsService(new CafeInstaller(
                                                                                new FileSystemCommandsBoundary(), processExecutor,
                                                                                UpdaterSettings.Instance.CafeApplicationDirectory));

            var runner = new OptionGroup()
                         .WithGroup("server", serverGroup =>
            {
                serverGroup.WithDefaultOption(new ServerInteractiveOption(application, ServiceFactory));
                serverGroup.WithOption(new ServerWindowsServiceOption(application, ServiceFactory),
                                       "--run-as-service");
            })
                         .WithGroup("service",
                                    serviceGroup =>
            {
                var fileSystem          = new FileSystem(new EnvironmentBoundary(), new FileSystemCommandsBoundary());
                var serviceStatusWaiter = new ServiceStatusWaiter("waiting for service status",
                                                                  new AutoResetEventBoundary(), new TimerFactory(),
                                                                  new ServiceStatusProvider(processExecutor,
                                                                                            fileSystem), application);
                ServiceOptionInitializer.AddServiceOptionsTo(serviceGroup, serviceStatusWaiter, processExecutor,
                                                             fileSystem, application, "cafe Updater", "updates cafe");
            })
                         .WithOption(new WaitForInstallOption(new FileSystemCommandsBoundary()), OptionValueSpecification.ForCommand("wait"),
                                     OptionValueSpecification.ForValue("installer:", "the name of the installer file that should be processed by the updater"));


            var arguments = runner.ParseArguments(args);

            if (arguments != null)
            {
                var returnValue = runner.RunProgram(arguments);
                Logger.Debug($"Finishing {application} run");
                return(returnValue);
            }
            else
            {
                Presenter.ShowError(
                    $"No options match the supplied arguments. Run {application} help to view all options",
                    Logger);
                return(-2);
            }
        }