Beispiel #1
0
 static async Task Main(string[] args)
 {
     var result = Parser.Default
                  .ParseArguments <DownloadCommand, InstallCommand, ListCommand, NewCommand>(args);
     await result.MapResult
     (
         async (DownloadCommand downloadCommand) =>
         await DownloadParser.Parse(downloadCommand),
         async (InstallCommand installCommand) =>
         await InstallParser.Parse(installCommand),
         async (ListCommand listCommand) => await Task.Run(() => ListParser.Parse()),
         async (NewCommand newCommand) => await NewParser.Parser(),
         async error => await Task.FromResult(1)
     );
 }
Beispiel #2
0
        public static async Task <int> Parser()
        {
            if (_parser == null)
            {
                _parser = new NewParser();
            }

            try
            {
                await _parser.New();

                return(0);
            }
            catch (Exception e)
            {
                Console.WriteLine("创建失败,错误信息:{0}", e.Message);
                return(1);
            }
        }