示例#1
0
    void CreateCommands()
    {
        QuitCommand  quitc  = QuitCommand.CreateCommand();
        ItemList     listc  = ItemList.CreateCommand();
        HelpCommand  helpc  = HelpCommand.CreateCommand();
        ClearCommand clearc = new ClearCommand();

        Log(string.Format("A total of {0} commands exist.", CommandList.Keys.Count));
        Log("Type 'help' for more info.");
    }
示例#2
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);
        }