Beispiel #1
0
        static void Main(string[] args)
        {
            var app = new CommandLineApplication(throwOnUnexpectedArg: false)
            {
                FullName = "HttpClient Factory Sample"
            };

            FactorySample.Register(app);
            TypedClientSample.Register(app);
            PolicySample.Register(app);
            UseClientHandlerSample.Register(app);

            app.Command("help", cmd =>
            {
                cmd.Description          = "Get help for the application";
                CommandArgument argument = cmd.Argument("<COMMAND>", "The command to get help for");
                cmd.OnExecute(() =>
                {
                    app.ShowHelp(argument.Value);
                    return(0);
                });
            });
            app.OnExecute(() =>
            {
                app.ShowHelp();
                return(0);
            });
            app.Execute(args);

            Console.WriteLine("bye");
        }
        internal static void Register(CommandLineApplication app)
        {
            app.Command("usehandler", cmd =>
            {
                cmd.Description = "Use a ClientMessageHandler";

                cmd.OnExecute(async() =>
                {
                    var sample = new UseClientHandlerSample();
                    await sample.RunAsync();
                    return(0);
                });
            });
        }