Example #1
0
        public async Task <int> Execute(string[] args)
        {
            var rootCommand = new RootCommand("Party: A Virt-A-Mate package manager")
            {
                HelpCommand.CreateCommand(_renderer, _config, _controllerFactory),
                SearchCommand.CreateCommand(_renderer, _config, _controllerFactory),
                GetCommand.CreateCommand(_renderer, _config, _controllerFactory),
                ShowCommand.CreateCommand(_renderer, _config, _controllerFactory),
                StatusCommand.CreateCommand(_renderer, _config, _controllerFactory),
                UpgradeCommand.CreateCommand(_renderer, _config, _controllerFactory),
                PublishCommand.CreateCommand(_renderer, _config, _controllerFactory),
                CleanCommand.CreateCommand(_renderer, _config, _controllerFactory),
            };

            // For CoreRT:
            rootCommand.Name = Path.GetFileName(Environment.GetCommandLineArgs().FirstOrDefault()) ?? "party.exe";

            Exception exc    = null;
            var       parser = new CommandLineBuilder(rootCommand)
                               .UseVersionOption()
                               .UseHelp()
#if DEBUG
                               .UseParseDirective()
                               .UseDebugDirective()
#endif
                               .UseSuggestDirective()
                               // .RegisterWithDotnetSuggest()
                               .UseTypoCorrections()
                               .UseParseErrorReporting()
                               .UseExceptionHandler((e, ctx) => exc = e)
                               .CancelOnProcessTermination()
                               .Build();

            _renderer.WriteLine("Party, a Virt-A-Mate package manager, is still in it's early stages. Please file any issue or ideas at https://github.com/vam-community/vam-party/issues", ConsoleColor.Green);

            try
            {
                await parser.InvokeAsync(args, _renderer);
            }
            catch (Exception e)
            {
                exc = e;
            }

            if (exc != null)
            {
                return(HandleError(exc));
            }

            return(0);
        }