Example #1
0
        public static async Task <int> Main(string[] args)
        {
            var command = new RootCommand()
            {
                Description = "Developer tools and publishing for microservices.",
            };

            // Show commandline help unless a subcommand was used.
            command.Handler = CommandHandler.Create <IHelpBuilder>(help =>
            {
                help.Write(command);
                return(1);
            });

            var builder = new CommandLineBuilder(command);

            builder.UseHelp();
            builder.UseVersionOption();
            builder.UseDebugDirective();
            builder.UseParseErrorReporting();
            builder.ParseResponseFileAs(ResponseFileHandling.ParseArgsAsSpaceSeparated);

            builder.CancelOnProcessTermination();
            builder.UseExceptionHandler(HandleException);

            var parser = builder.Build();

            return(await parser.InvokeAsync(args));
        }
Example #2
0
        static async Task <int> Main(string[] args)
        {
            var command = new RootCommand();

            command.Add(RunCommand(args));
            command.Add(NewCommand());

            command.Description = "Process manager and orchestrator for microservices.";

            var builder = new CommandLineBuilder(command);

            builder.UseHelp();
            builder.UseVersionOption();
            builder.UseDebugDirective();
            builder.UseParseErrorReporting();
            builder.ParseResponseFileAs(ResponseFileHandling.ParseArgsAsSpaceSeparated);
            builder.UsePrefixes(new[] { "-", "--", }); // disable garbage windows conventions

            builder.CancelOnProcessTermination();
            builder.UseExceptionHandler(HandleException);

            // Allow fancy drawing.
            builder.UseAnsiTerminalWhenAvailable();

            var parser = builder.Build();

            return(await parser.InvokeAsync(args));
        }
Example #3
0
        public static async Task <int> Main(string[] args)
        {
            var command = new RootCommand
            {
                Commands.Deploy.Command(),
                // ...add more commands here
            };

            command.Name        = "clud";
            command.Description = "clud deployment tool";

            // Show commandline help unless a sub-command was used.
            command.Handler = CommandHandler.Create <IHelpBuilder>(help =>
            {
                ConsoleHelpers.PrintLogo();
                help.Write(command);
                return(1);
            });

            var builder = new CommandLineBuilder(command);

            builder.UseHelp();
            builder.UseVersionOption();
            builder.UseDebugDirective();
            builder.UseParseErrorReporting();
            builder.ParseResponseFileAs(ResponseFileHandling.ParseArgsAsSpaceSeparated);

            builder.CancelOnProcessTermination();
            builder.UseExceptionHandler(HandleException);

            var parser = builder.Build();

            return(await parser.InvokeAsync(args));
        }
Example #4
0
        public static async Task <int> Main(string[] args)
        {
            var command = new RootCommand();

            command.Add(ScrapeCommand.Create());
            command.Description = "Scrapes test results from AzDO, xUnit files, etc. and stores it in a database.";

            var builder = new CommandLineBuilder(command);

            builder.UseHelp();
            builder.UseVersionOption();
            builder.UseDebugDirective();
            builder.UseParseErrorReporting();
            builder.ParseResponseFileAs(ResponseFileHandling.ParseArgsAsSpaceSeparated);
            builder.UsePrefixes(new[] { "-", "--", }); // disable garbage windows conventions

            builder.CancelOnProcessTermination();
            builder.UseExceptionHandler(HandleException);

            // Allow fancy drawing.
            builder.UseAnsiTerminalWhenAvailable();

            var parser = builder.Build();

            return(await parser.InvokeAsync(args));
        }
Example #5
0
        public static Task <int> Main(string[] args)
        {
            var root = new RootCommand();

            root.Handler = CommandHandler.Create <IConsole, IHelpBuilder>((console, help) =>
            {
                // looks a bit gross but avoids a newline
                console.Out.Write(@"   _____      __                         __  _
  / ___/_____/ /_  ___  ____ ___  ____ _/ /_(_)____
  \__ \/ ___/ __ \/ _ \/ __ `__ \/ __ `/ __/ / ___/
 ___/ / /__/ / / /  __/ / / / / / /_/ / /_/ / /__
/____/\___/_/ /_/\___/_/ /_/ /_/\__,_/\__/_/\___/

The helpful database schema querying tool.

");

                help.Write(root);
                return(1);
            });

            var configFileOption = new Option <FileInfo>(
                "--config",
                getDefaultValue: () => new FileInfo(
                    Path.Combine(Directory.GetCurrentDirectory(),
                                 "schematic.config.json"
                                 )),
                description: "A path to a configuration file used to retrieve options such as connection strings."
                ).ExistingOnly();

            root.AddGlobalOption(configFileOption);

            root.AddCommand(new OrmCommand());
            root.AddCommand(new LintCommand());
            root.AddCommand(new ReportCommand());
            root.AddCommand(new TestCommand());

            var builder = new CommandLineBuilder(root);

            builder.UseHelp();
            builder.UseVersionOption();
            builder.UseDebugDirective();
            builder.UseParseErrorReporting();
            builder.ParseResponseFileAs(ResponseFileHandling.ParseArgsAsSpaceSeparated);
            builder.CancelOnProcessTermination();
            builder.UseExceptionHandler(HandleException);

            var parser = builder.Build();

            return(parser.InvokeAsync(args));
        }
Example #6
0
        static async Task Main(string[] args)
        {
            var command = new RootCommand("Run a .NET Framework website in IIS")
            {
                new Argument <DirectoryInfo?>(CLIHelper.ParsePath <DirectoryInfo>)
                {
                    Arity       = ArgumentArity.ExactlyOne,
                    Description = "The relative or absolute path to the .NET Framework project directory",
                    Name        = "path",
                },
                new Argument <DirectoryInfo?>(CLIHelper.ParsePath <DirectoryInfo>)
                {
                    Arity       = ArgumentArity.ZeroOrOne,
                    Description = "The relative or absolute path to the solution directory",
                    Name        = "solutionPath"
                },
                new Option("--no-build", "Do not build the website before launching it"),
                new Option("--name", "The name of the website")
                {
                    Argument = new Argument <string>("name")
                },
                new Option("--port", "The port that the website should listen on")
                {
                    Argument = new Argument <int>("port")
                }
            };

            command.Handler = CommandHandler.Create <CommandArguments>(async arg =>
            {
                if (string.IsNullOrEmpty(arg.Path?.FullName))
                {
                    throw new Exception("Argument 'path' is required.");
                }

                var environmentVariables = EnvironmentHelper.LoadEnvironmentVariables();

                await using var iisHost = new IISHost(environmentVariables);
                await iisHost.Run(arg.Console, arg, arg.Token);
            });

            var builder = new CommandLineBuilder(command);

            builder.UseHelp();
            builder.UseDebugDirective();
            builder.UseExceptionHandler(CLIHelper.HandleException);
            builder.CancelOnProcessTermination();

            var parser = builder.Build();
            await parser.InvokeAsync(args);
        }
Example #7
0
        public static async Task <int> Main(string[] args)
        {
            // Create a root command with some options
            var command = new RootCommand();

            command.Add(Commands.RunCronJob(args));

            command.Description = "Worker/Cronjob Example";

            var builder = new CommandLineBuilder(command);

            builder.UseHelp();
            builder.UseVersionOption();
            builder.UseDebugDirective();
            builder.UseParseErrorReporting();
            builder.ParseResponseFileAs(ResponseFileHandling.ParseArgsAsSpaceSeparated);
            builder.UsePrefixes(new[] { "-", "--", }); // disable garbage windows conventions

            builder.CancelOnProcessTermination();

            builder.CancelOnProcessTermination();
            builder.UseExceptionHandler(HandleException);

            // Allow fancy drawing.
            builder.UseAnsiTerminalWhenAvailable();

            // default
            command.Handler = CommandHandler.Create <IConsole>(console =>
            {
                CreateHostBuilder(args).Build().Run();
            });

            var parser = builder.Build();

            return(await parser.InvokeAsync(args));
        }
Example #8
0
        static async Task Main(string[] args)
        {
            var command = new RootCommand("Run a .NET Framework project")
            {
                new Argument <DirectoryInfo?>(CLIHelper.ParsePath <DirectoryInfo>)
                {
                    Arity       = ArgumentArity.ExactlyOne,
                    Description = "The relative or absolute path to the .NET Framework project directory",
                    Name        = "path"
                },
                new Argument <DirectoryInfo?>(CLIHelper.ParsePath <DirectoryInfo>)
                {
                    Arity       = ArgumentArity.ZeroOrOne,
                    Description = "The relative or absolute path to the solution directory",
                    Name        = "solutionPath"
                },
                new Option <bool>("--no-restart", "Keep running project even after rebuilds")
                {
                    IsRequired = false
                }
            };

            command.Handler = CommandHandler.Create <CommandArguments>(async arg =>
            {
                if (string.IsNullOrEmpty(arg.Path?.FullName))
                {
                    throw new Exception("Argument 'path' is required.");
                }

                arg.Arguments = CLIHelper.ParseArguments();

                await using var dnfHost = new DNFHost();
                await dnfHost.Run(arg.Console, arg, arg.Token);
            });

            var builder = new CommandLineBuilder(command);

            builder.UseHelp();
            builder.UseDebugDirective();
            builder.UseExceptionHandler(CLIHelper.HandleException);
            builder.CancelOnProcessTermination();

            var parser = builder.Build();
            await parser.InvokeAsync(args);
        }
Example #9
0
        private static Task Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration().MinimumLevel.Debug().WriteTo.Console().CreateLogger();

            var serviceCollection = new ServiceCollection();

            var command = new RootCommand {
                Description = "Nauta command line tool."
            };

            command.AddCommand(CreateCredentialsCommand());
            command.AddCommand(CreateOpenCommand());
            command.AddCommand(CreateCloseCommand());
            command.AddCommand(CreateTimeCommand());

            // Show commandline help unless a subcommand was used.
            command.Handler = CommandHandler.Create <IHelpBuilder>(
                help =>
            {
                help.Write(command);
                return(1);
            });

            var builder = new CommandLineBuilder(command);

            builder.UseExceptionHandler(
                (exception, context) =>
            {
                Log.Error(exception, "Error executing command '{command}'.", context.ParseResult.CommandResult.Token.Value);
            });

            builder.UseHelp();
            builder.UseVersionOption();
            builder.UseDebugDirective();
            builder.UseParseErrorReporting();
            builder.ParseResponseFileAs(ResponseFileHandling.ParseArgsAsSpaceSeparated);
            builder.CancelOnProcessTermination();

            var parser = builder.Build();

            return(parser.InvokeAsync(args));
        }
Example #10
0
        public static Task <int> Main(string[] args)
        {
            var command = new RootCommand()
            {
                Description = "Developer tools and publishing for microservices.",
            };

            command.AddGlobalOption(StandardOptions.NoDefaultOptions);

            command.AddCommand(CreateInitCommand());
            command.AddCommand(CreateGenerateCommand());
            command.AddCommand(CreateRunCommand());
            command.AddCommand(CreateBuildCommand());
            command.AddCommand(CreatePushCommand());
            command.AddCommand(CreateDeployCommand());
            command.AddCommand(CreateUndeployCommand());

            // Show commandline help unless a subcommand was used.
            command.Handler = CommandHandler.Create <IHelpBuilder>(help =>
            {
                help.Write(command);
                return(1);
            });

            var builder = new CommandLineBuilder(command);

            builder.UseHelp();
            builder.UseVersionOption();
            builder.UseDebugDirective();
            builder.UseParseErrorReporting();
            builder.ParseResponseFileAs(ResponseFileHandling.ParseArgsAsSpaceSeparated);

            builder.CancelOnProcessTermination();
            builder.UseExceptionHandler(HandleException);

            builder.UseMiddleware(DefaultOptionsMiddleware);

            var parser = builder.Build();

            return(parser.InvokeAsync(args));
        }
Example #11
0
        public static async Task <int> Main(string[] args)
        {
            RootCommand rootCommand = new RootCommand("Atari Lynx Command-line Interface");

            rootCommand.AddCommand(new ComLynxCommand());
            rootCommand.AddCommand(new BllCommand());
            rootCommand.AddCommand(new FlashcardCommand());

            // Show commandline help unless a subcommand was used.
            rootCommand.Handler = CommandHandler.Create <IHelpBuilder>(help =>
            {
                help.Write(rootCommand);
                return(1);
            });

            var verboseOption = new Option <bool>("--verbose", "Show verbose output");

            verboseOption.AddAlias("-v");
            rootCommand.TryAddGlobalOption(verboseOption);

            var builder = new CommandLineBuilder(rootCommand);

            builder.UseHelp();
            builder.UseVersionOption();
            builder.UseDebugDirective();
            builder.UseParseErrorReporting();
            builder.ParseResponseFileAs(ResponseFileHandling.ParseArgsAsSpaceSeparated);

            builder.CancelOnProcessTermination();
            builder.UseExceptionHandler(HandleException);

            //builder.UseMiddleware(DefaultOptionsMiddleware);

            var parser = builder.Build();

            return(await parser.InvokeAsync(args));

            //return await rootCommand.InvokeAsync(args);
        }
Example #12
0
        static async Task <int> Main(string[] args)
        {
            var command = new RootCommand();

            command.AddCommand(DeployCommand.Create());
            command.AddCommand(InitCommand.Create());
            command.AddCommand(GenerateCommand.Create());
            command.AddCommand(PackageCommand.Create());
            command.AddCommand(PushCommand.Create());

            command.Description = "white-glove service for .NET and kubernetes";
            command.Handler     = CommandHandler.Create <IHelpBuilder>(help =>
            {
                help.Write(command);
                return(1);
            });

            var builder = new CommandLineBuilder(command);

            // Parsing behavior
            builder.UseHelp();
            builder.UseVersionOption();
            builder.UseDebugDirective();
            builder.UseParseErrorReporting();
            builder.ParseResponseFileAs(ResponseFileHandling.ParseArgsAsSpaceSeparated);
            builder.UsePrefixes(new [] { "-", "--", }); // disable garbage windows conventions

            builder.CancelOnProcessTermination();
            builder.UseExceptionHandler(HandleException);

            // Allow fancy drawing.
            builder.UseAnsiTerminalWhenAvailable();

            var parser = builder.Build();

            return(await parser.InvokeAsync(args));
        }
Example #13
0
        static async Task <int> Main(string[] args)
        {
            var command = new RootCommand("Dumps usage of PlatformNotSupportedException");

            var directoryArgument = new Argument <DirectoryInfo>();

            directoryArgument.SetDefaultValue(new DirectoryInfo(Environment.CurrentDirectory));
            directoryArgument.ExistingOnly();

            command.AddOption(new Option(new[] { "-d", "--directory", })
            {
                Argument = directoryArgument,
                Required = false,
            });

            command.Handler = CommandHandler.Create <IConsole, DirectoryInfo>(async(console, directory) =>
            {
                await Dumper.DumpAsync(console, directory);
            });

            var builder = new CommandLineBuilder(command);

            // Parsing behavior
            builder.UseHelp();
            builder.UseVersionOption();
            builder.UseDebugDirective();
            builder.UseParseErrorReporting();
            builder.ParseResponseFileAs(ResponseFileHandling.ParseArgsAsSpaceSeparated);
            builder.UsePrefixes(new[] { "-", "--", }); // disable garbage windows conventions

            builder.CancelOnProcessTermination();
            builder.UseExceptionHandler(HandleException);

            var parser = builder.Build();

            return(await parser.InvokeAsync(args));
        }