static void Main(string[] args)
        {
            var rootCommand = new RootCommand();

            {
                var fileCommand = new Command("file");
                rootCommand.AddCommand(fileCommand);
                var io = new Option <string>("--input", description: "The file to trim.");
                io.AddAlias("-i");
                fileCommand.AddOption(io);
                fileCommand.Handler = CommandHandler.Create <string>(async(string input) =>
                {
                    //Parse a file of markers into an in-out list for use with the automator.
                    var engine = new Engine(SmpteFrameRate.Smpte25, 10.0);
                    await engine.ParseMarkersFileAsync(input);
                });
            }
            {
                var directoryCommand = new Command("directory");
                rootCommand.AddCommand(directoryCommand);
                var io = new Option <string>("--input", description: "The file to trim.");
                io.AddAlias("-i");
                directoryCommand.AddOption(io);
                directoryCommand.Handler = CommandHandler.Create <string>(async(string input) =>
                {
                    foreach (var fi in new DirectoryInfo(input).GetFiles())
                    {
                        //Parse a file of markers into an in-out list for use with the automator.
                        var engine = new Engine(SmpteFrameRate.Smpte25, 15.0);
                        await engine.ParseMarkersFileAsync(fi.FullName);
                    }
                });
            }
            rootCommand.Invoke(args);
        }
예제 #2
0
        public int Run(string[] args)
        {
            Logger.Info(() => "Logging configured.");

            var rootCommand  = new RootCommand();
            var buildCommand = new Command("build", "Generates C# code, database model file and other project assets.");

            // CurrentDirectory by default, because rhetos.exe on *build* is expected to be located in NuGet package cache.
            buildCommand.Add(new Argument <DirectoryInfo>("project-root-folder", () => new DirectoryInfo(Environment.CurrentDirectory))
            {
                Description = "Project folder where csproj file is located. If not specified, current working directory is used by default."
            });
            buildCommand.Add(new Option <bool>("--msbuild-format", false, "Adjust error output format for MSBuild integration."));
            buildCommand.Handler = CommandHandler.Create((DirectoryInfo projectRootFolder, bool msbuildFormat)
                                                         => ReportError(() => Build(projectRootFolder.FullName), msbuildFormat));
            rootCommand.AddCommand(buildCommand);

            var dbUpdateCommand = new Command("dbupdate", "Updates the database structure and initializes the application data in the database.");

            dbUpdateCommand.Add(new Argument <DirectoryInfo>("application-folder", () => new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory))
            {
                Description = "If not specified, it will search for the application at rhetos.exe location and parent directories."
            });
            dbUpdateCommand.Add(new Option <bool>("--short-transactions", "Commit transaction after creating or dropping each database object."));
            dbUpdateCommand.Add(new Option <bool>("--skip-recompute", "Skip automatic update of computed data with KeepSynchronized. See output log for data that needs updating."));
            dbUpdateCommand.Handler = CommandHandler.Create((DirectoryInfo applicationFolder, bool shortTransactions, bool skipRecompute)
                                                            => ReportError(() => DbUpdate(applicationFolder, shortTransactions, skipRecompute)));
            rootCommand.AddCommand(dbUpdateCommand);

            return(rootCommand.Invoke(args));
        }
        public static async Task Invokes_DerivedClass()
        {
            var service = new MyService();

            var cmd = new RootCommand();

            cmd.AddCommand(new MyCommand());
            cmd.AddCommand(new MyOtherCommand());
            var parser = new CommandLineBuilder(cmd)
                         .UseHost((builder) => {
                builder.ConfigureServices(services =>
                {
                    services.AddTransient(x => service);
                })
                .UseCommandHandler <MyCommand, MyCommand.MyDerivedHandler>()
                .UseCommandHandler <MyOtherCommand, MyOtherCommand.MyDerivedHandler>();
            })
                         .Build();

            await parser.InvokeAsync(new string[] { "mycommand", "--int-option", "54" });

            service.Value.Should().Be(54);

            await parser.InvokeAsync(new string[] { "myothercommand", "TEST" });

            service.StringValue.Should().Be("TEST");
        }
예제 #4
0
        public static Task <int> Main(string[] args)
        {
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                Console.WriteLine("This tool is not supported on non-Windows platforms due to dependencies on Visual Studio.");
                return(Task.FromResult(ErrorCodes.PlatformNotSupported));
            }

            var root = new RootCommand
            {
                // Get name from process so that it will show correctly if run as a .NET CLI tool
                Name = GetProcessName(),
            };

#if ANALYZE_COMMAND
            var upgradeCmd = new Command("upgrade");
            ConfigureUpgradeCommand(upgradeCmd);
            root.AddCommand(upgradeCmd);

            var analyzeCmd = new Command("analyze");
            ConfigureAnalyzeCommand(analyzeCmd);
            root.AddCommand(analyzeCmd);
#else
            ConfigureUpgradeCommand(root);
#endif

            return(new CommandLineBuilder(root)
                   .UseDefaults()
                   .UseHelpBuilder(b => new HelpWithHeader(b.Console))
                   .Build()
                   .InvokeAsync(args));
예제 #5
0
        public static void RegisterCommands(RootCommand rootCommand)
        {
            rootCommand.AddCommand(new Command("list", "Lists installed packages")
            {
                Handler = CommandHandler.Create(List)
            });

            Command search = new Command("search", "Search for packages")
            {
                new Option <string>(new[] { "--identifier", "-i" }, "Something to identify the app")
                {
                    Required = true
                }
            };

            search.Handler = CommandHandler.Create <string>(Search);
            rootCommand.AddCommand(search);

            Command show = new Command("show", "Shows package info")
            {
                new Option <string>(new[] { "--identifier", "-i" }, "Something to identify the app")
                {
                    Required = true
                }
            };

            show.Handler = CommandHandler.Create <string>(Show);
            rootCommand.AddCommand(show);

            rootCommand.AddCommand(new Command("update", "Updates the cache")
            {
                Handler = CommandHandler.Create(Update)
            });
        }
예제 #6
0
    /// <summary>
    /// Takes a list of gamertags in csv format (with their xuid and last weeks gamerscore),
    /// polls the open XBL api for their current gamerscore and outputs the (weekly) leaderboard
    /// in a table format Discourse understands.
    ///
    /// operates in 2 different modes:
    /// - if the caller specifies option --weekly the programm scans the path for the last
    ///   weekly file, calculates the weekly diff and writes the new weekly and global scores
    ///   to a new file in the path. it also writes a second text file in Discourse format.
    /// - if the caller specifies option --monthly the programm first scans all users for
    ///   the highest score for the monthly game (this games name is either specified on the
    ///   commandline or in lastscanstats.txt). The the program searches the path for the last
    ///   monthly file, calculates the monthly diff and writes the new monthly and global scores
    ///   to a new file in the path. it also writes a second text file in Discourse format.
    /// </summary>
    public static int Main(string[] args)
    {
        var gameOption = new Option <string>(name: "--game",
                                             description: "title-id of monthly game",
                                             getDefaultValue: () => string.Empty);
        var pathArg = new Argument <string>(name: "path",
                                            description: "path to scores scores directory",
                                            getDefaultValue: () => @"./docs/scores");

        var rootCommand = new RootCommand("Batch app for building the weekly or monthly Xboxera leaderboard");

        var weeklyCommand = new Command("weekly", "generate weekly leaderboard data");

        weeklyCommand.AddArgument(pathArg);
        weeklyCommand.AddOption(gameOption);
        weeklyCommand.SetHandler <string, string>(HandleWeeklyCommand, pathArg, gameOption);
        rootCommand.AddCommand(weeklyCommand);

        var monthlyCommand = new Command("monthly", "generate monthly leaderboard data");

        monthlyCommand.AddArgument(pathArg);
        monthlyCommand.AddOption(gameOption);
        monthlyCommand.SetHandler <string, string>(HandleMonthlyCommand, pathArg, gameOption);
        rootCommand.AddCommand(monthlyCommand);

        return(rootCommand.Invoke(args));
    }
예제 #7
0
        private static int Main(string[] args)
        {
            var calc        = new Calculation();
            var rootCommand = new RootCommand
            {
                new Option <string>(
                    "--from",
                    getDefaultValue: () => "NK",
                    description: "From currency. Should be of valid currency symbol. Check --symbols for list."),
                new Option <string>(
                    "--to",
                    getDefaultValue: () => "SEK",
                    description: "To currency. Should be of valid currency symbol. Check --symbols for list."),
                new Option <string>(
                    "--date",
                    getDefaultValue: () => "latest",
                    description: "Date in format yyyy-dd-mm for historical data"),
                new Option <decimal>(
                    "--amount",
                    getDefaultValue: () => 1,
                    "Amount of currency to convert in dot decimal format. Amount is given in the 'to' currency.")
            };

            rootCommand.Description = "Currencyconverter. Takes a valid currency symbol as --to and --from and converts.";
            rootCommand.Handler     = CommandHandler.Create <string, string, string, decimal>(async(from, to, date, amount) =>
            {
                var result = await calc.FromToAmount(from.ToUpper(), to.ToUpper(), amount, date);
                Console.WriteLine(result);
            });
            rootCommand.AddCommand(getSymbols());
            rootCommand.AddCommand(getAllRates());
            // Parse the incoming args and invoke the handler
            return(rootCommand.InvokeAsync(args).Result);
        }
예제 #8
0
파일: Program.cs 프로젝트: weirdyang/tye
        public static Task <int> Main(string[] args)
        {
            var command = new RootCommand()
            {
                Description = "Developer tools and publishing for microservices.",
            };

            command.AddCommand(CreateInitCommand());
            command.AddCommand(CreateGenerateCommand());
            command.AddCommand(CreateRunCommand(args));
            command.AddCommand(CreateBuildCommand());
            command.AddCommand(CreateDeployCommand());

            // 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(parser.InvokeAsync(args));
        }
        public static async Task Can_have_diferent_handlers_based_on_command()
        {
            var root = new RootCommand();

            root.AddCommand(new MyCommand());
            root.AddCommand(new MyOtherCommand());
            var parser = new CommandLineBuilder(root)
                         .UseHost(host =>
            {
                host.ConfigureServices(services =>
                {
                    services.AddTransient <MyService>(_ => new MyService()
                    {
                        Action = () => 100
                    });
                })
                .UseCommandHandler <MyCommand, MyCommand.MyHandler>()
                .UseCommandHandler <MyOtherCommand, MyOtherCommand.MyHandler>();
            })
                         .Build();

            var result = await parser.InvokeAsync(new string[] { "mycommand", "--int-option", "54" });

            result.Should().Be(54);

            result = await parser.InvokeAsync(new string[] { "myothercommand", "--int-option", "54" });

            result.Should().Be(100);
        }
예제 #10
0
        private static int Main(string[] args)
        {
            System.Console.WriteLine("====================================================");
            System.Console.WriteLine($"{SokoSolveApp.Name} :: v{SokoSolveApp.Version}");
            System.Console.WriteLine(DevHelper.FullDevelopmentContext());
            System.Console.WriteLine("----------------------------------------------------");
            System.Console.WriteLine();

            var root = new RootCommand();

            root.AddCommand(BenchmarkCommand.GetCommand());

            //------------------------------------------------------------------------------------------------------------
            var play = new Command("play", "Play SokoSolve game in the console")
            {
                Handler = CommandHandler.Create(PlayCommand.Run)
            };

            root.AddCommand(play);
            //------------------------------------------------------------------------------------------------------------
            var micro = new Command("micro", "Micro Benchmarks (BenchmarkDotNet)")
            {
                new Argument <string>(() => "BaseLineSolvers")
                {
                    Name        = "target",
                    Description = "Target Type"
                },
            };

            micro.Handler = CommandHandler.Create <string>(MicroCommand.Run);
            root.AddCommand(micro);
            //------------------------------------------------------------------------------------------------------------

            return(root.Invoke(args));
        }
예제 #11
0
        static async Task Main(string[] args)
        {
            var cli = new RootCommand("Otc.Messaging.RabbitMQ.Cli");

            SetupGlobalOptions(cli);

            // Setup available commands
            cli.AddCommand(CreateSimpleQueue.Setup());
            cli.AddCommand(CreateMultipleQueues.Setup());
            cli.AddCommand(CreateVirtualHost.Setup());
            cli.AddCommand(ApplyMirrorPolicy.Setup());

            // Parse command line arguments
            var parsed = cli.Parse(args);

            // Sets global options
            Broker.Host        = parsed.CommandResult.ValueForOption <string>("--host");
            Broker.Port        = parsed.CommandResult.ValueForOption <int>("--port");
            Broker.ApiPort     = parsed.CommandResult.ValueForOption <int>("--apiport");
            Broker.User        = parsed.CommandResult.ValueForOption <string>("--user");
            Broker.Password    = parsed.CommandResult.ValueForOption <string>("--pass");
            Broker.VirtualHost = parsed.CommandResult.ValueForOption <string>("--vhost");

            // Invoke execution
            await cli.InvokeAsync(args);
        }
예제 #12
0
        public static void RegisterCommands(RootCommand rootCommand)
        {
            rootCommand.AddCommand(new Command("list-repo", "Lists current repositories")
            {
                Handler = CommandHandler.Create(ListRepo)
            });

            Command addRepo = new Command("add-repo", "Adds a repository")
            {
                new Option <string>(new[] { "--name", "-n" }, "The new repositories name")
                {
                    Required = true
                },
                new Option <string>(new[] { "--link", "-l" }, "A link to the repositories XML")
                {
                    Required = true
                }
            };

            addRepo.Handler = CommandHandler.Create <string, string>(AddRepo);
            rootCommand.AddCommand(addRepo);

            Command removeRepo = new Command("remove-repo", "Removes a repository")
            {
                new Option <string>(new[] { "--name", "-n" }, "The repositories name")
                {
                    Required = true
                }
            };

            removeRepo.Handler = CommandHandler.Create <string>(RemoveRepo);
            rootCommand.AddCommand(removeRepo);
        }
예제 #13
0
        private static RootCommand CreateCommandLineOptions()
        {
            // Root command and global options
            RootCommand rootCommand = new RootCommand("Utility to automate iterative IO performance tests.");

            // Path to the settings file must always be specified
            rootCommand.AddOption(
                new Option <string>("--settings")
            {
                Description = "Path to settings file.",
                Required    = true
            });

            // Write defaults to settings file
            rootCommand.AddCommand(
                new Command("writedefaults")
            {
                Description = "Write default values to settings file.",
                Handler     = CommandHandler.Create <string>(WriteDefaultsCommand)
            });

            // Run test
            rootCommand.AddCommand(
                new Command("runtests")
            {
                Description = "Run all tests.",
                Handler     = CommandHandler.Create <string>(RunTestsCommand)
            });

            return(rootCommand);
        }
예제 #14
0
        private static RootCommand CreateRootCommand()
        {
            var torrentOpt =
                new Option <FileInfo>(
                    new[] { "--torrent", "-t" },
                    "The .torrent file to operate on"
                    )
            {
                IsRequired = true
            };

            var prog    = new Program();
            var rootCmd = new RootCommand("IOU torrent CLI");

            var summaryCommand = new Command("summary", "Summarize torrent info");

            summaryCommand.AddArgument(new Argument <FileInfo>("torrent"));
            summaryCommand.Handler = CommandHandler.Create <FileInfo>(prog.SummarizeTorrent);

            var dhtCommand = new Command("dht", "Dump DHT info");

            dhtCommand.Handler = CommandHandler.Create(async() => {
                var ip = await AskPublicIpAddressAsync();
                Console.WriteLine($"IP: {ip}");
            });

            rootCmd.AddCommand(new TorrentCommand());
            rootCmd.AddCommand(dhtCommand);

            return(rootCmd);
        }
        public static void Main(string[] args)
        {
            var fhirServerOption = new Option(
                OptionAliases.FhirServer,
                Resources.FhirServerOptionDescription,
                new Argument <Uri> {
                Arity = ArgumentArity.ExactlyOne
            });

            var connectionStringOption = new Option(
                OptionAliases.ConnectionString,
                Resources.ConnectionStringOptionDescription,
                new Argument <string> {
                Arity = ArgumentArity.ExactlyOne
            });

            var versionOption = new Option(
                OptionAliases.Version,
                Resources.VersionOptionDescription,
                new Argument <int> {
                Arity = ArgumentArity.ExactlyOne
            });

            var rootCommand = new RootCommand();

            var currentCommand = new Command(CommandNames.Current, Resources.CurrentCommandDescription)
            {
                fhirServerOption,
            };

            currentCommand.Handler = CommandHandler.Create <Uri>(CurrentCommand.Handler);
            currentCommand.Argument.AddValidator(symbol => Validators.RequiredOptionValidator.Validate(symbol, fhirServerOption, Resources.FhirServerRequiredValidation));

            var applyCommand = new Command(CommandNames.Apply, Resources.ApplyCommandDescription)
            {
                connectionStringOption,
                fhirServerOption,
                versionOption,
            };

            applyCommand.Handler = CommandHandler.Create <string, Uri, int>(ApplyCommand.Handler);
            applyCommand.Argument.AddValidator(symbol => Validators.RequiredOptionValidator.Validate(symbol, connectionStringOption, Resources.ConnectionStringRequiredValidation));
            applyCommand.Argument.AddValidator(symbol => Validators.RequiredOptionValidator.Validate(symbol, fhirServerOption, Resources.FhirServerRequiredValidation));
            applyCommand.Argument.AddValidator(symbol => Validators.RequiredOptionValidator.Validate(symbol, versionOption, Resources.VersionRequiredValidation));

            var availableCommand = new Command(CommandNames.Available, Resources.AvailableCommandDescription)
            {
                fhirServerOption,
            };

            availableCommand.Handler = CommandHandler.Create <InvocationContext, Uri>(AvailableCommand.Handler);
            availableCommand.Argument.AddValidator(symbol => Validators.RequiredOptionValidator.Validate(symbol, fhirServerOption, Resources.FhirServerRequiredValidation));

            rootCommand.AddCommand(applyCommand);
            rootCommand.AddCommand(availableCommand);
            rootCommand.AddCommand(currentCommand);

            rootCommand.InvokeAsync(args).Wait();
        }
예제 #16
0
파일: Program.cs 프로젝트: ehamberg/fplbot
        private static CommandLineBuilder BuildCommandLine()
        {
            var root = new RootCommand();

            root.AddCommand(IndexCommand.Create());
            root.AddCommand(SearchCommand.Create());
            return(new CommandLineBuilder(root));
        }
예제 #17
0
        static int Main(string[] args)
        {
            var rootCommand = new RootCommand();

            rootCommand.AddCommand(CreateServiceCommand.Create());
            rootCommand.AddCommand(CreateSocketCommand.Create());
            return(rootCommand.InvokeAsync(args).Result);
        }
예제 #18
0
        static async Task <int> Main(string[] args)
        {
            var cmd = new RootCommand();

            cmd.AddCommand(Helloworld());
            cmd.AddCommand(SalutaConNome());
            return(await cmd.InvokeAsync(args));
        }
예제 #19
0
        static async Task <int> Main(string[] args)
        {
            var rootCommand = new RootCommand();

            rootCommand.AddCommand(GetEncryptCommand());
            rootCommand.AddCommand(GetDecryptCommand());

            return(await rootCommand.InvokeAsync(args).ConfigureAwait(false));
        }
예제 #20
0
        public Parser Create(
            EnvironmentInit environmentInit = null,
            NewFile newFile                     = null,
            PluginInstall pluginInstall         = null,
            PluginUninstall pluginUninstall     = null,
            PluginList pluginList               = null,
            SetUsername setEnvironmentSetting   = null,
            TemplateInstall templateInstall     = null,
            TemplateUninstall templateUninstall = null)
        {
            // if environmentInit hasn't been provided (for testing) then assign the Command Handler
            environmentInit ??= EnvironmentInitHandler.ExecuteAsync;
            newFile ??= NewFileHandler.ExecuteAsync;
            pluginInstall ??= PluginInstallHandler.ExecuteAsync;
            pluginUninstall ??= PluginUninstallHandler.ExecuteAsync;
            pluginList ??= PluginListHandler.ExecuteAsync;
            setEnvironmentSetting ??= SetEnvironmentSettingHandler.ExecuteAsync;
            templateInstall ??= TemplatePackageInstallerHandler.ExecuteAsync;
            templateUninstall ??= TemplatePackageUninstallerHandler.ExecuteAsync;

            // Set up intrinsic commands that will always be available.
            RootCommand rootCommand = Root();

            rootCommand.AddCommand(Environment());
            rootCommand.AddCommand(NewFile());
            rootCommand.AddCommand(Plugins());
            rootCommand.AddCommand(Templates());

            var commandBuilder = new CommandLineBuilder(rootCommand);

            try
            {
                foreach (Command command in this.commandPluginHost.Discover(this.appEnvironment.PluginPaths))
                {
                    commandBuilder.AddCommand(command);
                }
            }
            catch (DirectoryNotFoundException)
            {
                // If this is the first run, initialize the environment and default plugins
                Console.WriteLine("Error Detected: vellum environment uninitialized.");
                Parser parser = commandBuilder.UseDefaults().Build();

                int result = parser.Invoke("environment init");

                if (result == ReturnCodes.Ok)
                {
                    // Now the environment has been re-initialized, try to discover the plugins again.
                    foreach (Command command in this.commandPluginHost.Discover(this.appEnvironment.PluginPaths))
                    {
                        commandBuilder.AddCommand(command);
                    }
                }
            }

            return(commandBuilder.UseDefaults().Build());
예제 #21
0
        public override Command Configure()
        {
            RootCommand res = new RootCommand(Program.AppDescription);

            res.AddCommand(new ConfigCommand().Build());
            res.AddCommand(new ExtensionCommand().Build());
            res.AddCommand(new CommandCommand().Build());
            res.AddCommand(new WorkspaceCommand().Build());
            return(res);
        }
예제 #22
0
        static CommandLineConfigs()
        {
            DryRunCommand.AddAlias(WhatIfCommandName);

            UninstallRootCommand.AddCommand(ListCommand);
            UninstallRootCommand.AddCommand(DryRunCommand);
            UninstallRootCommand.AddCommand(RemoveCommand);

            var supportedBundleTypeNames = SupportedBundleTypeConfigs.GetSupportedBundleTypes().Select(type => type.OptionName);

            RemoveAuxOptions = UninstallBundleTypeOptions
                               .Where(option => supportedBundleTypeNames.Contains(option.Name))
                               .Concat(AdditionalUninstallOptions)
                               .Append(YesOption);
            if (RuntimeInfo.RunningOnWindows)
            {
                RemoveAuxOptions = RemoveAuxOptions.Concat(ArchUninstallOptions);
            }
            AssignOptionsToCommand(RemoveCommand, RemoveAuxOptions
                                   .Concat(UninstallFilterBundlesOptions), true);

            DryRunAuxOptions = UninstallBundleTypeOptions
                               .Where(option => supportedBundleTypeNames.Contains(option.Name))
                               .Concat(AdditionalUninstallOptions);
            if (RuntimeInfo.RunningOnWindows)
            {
                DryRunAuxOptions = DryRunAuxOptions.Concat(ArchUninstallOptions);
            }
            AssignOptionsToCommand(DryRunCommand, DryRunAuxOptions
                                   .Concat(UninstallFilterBundlesOptions), true);

            ListAuxOptions = ListBundleTypeOptions
                             .Where(option => supportedBundleTypeNames.Contains(option.Name))
                             .Append(VerbosityOption);
            if (RuntimeInfo.RunningOnWindows)
            {
                ListAuxOptions = ListAuxOptions
                                 .Append(ListX64Option)
                                 .Append(ListX86Option);
            }
            AssignOptionsToCommand(ListCommand, ListAuxOptions);

            var bundleCollector = RuntimeInfo.RunningOnWindows ? new RegistryQuery() as IBundleCollector : new FileSystemExplorer() as IBundleCollector;

            ListCommand.Handler   = CommandHandler.Create(ExceptionHandler.HandleException(() => ListCommandExec.Execute(bundleCollector)));
            DryRunCommand.Handler = CommandHandler.Create(ExceptionHandler.HandleException(() => DryRunCommandExec.Execute(bundleCollector)));
            RemoveCommand.Handler = CommandHandler.Create(ExceptionHandler.HandleException(() => UninstallCommandExec.Execute(bundleCollector)));

            UninstallCommandParser = new CommandLineBuilder(UninstallRootCommand)
                                     .UseDefaults()
                                     .UseVersionOption()
                                     .UseHelpBuilder(context => new UninstallHelpBuilder(context.Console))
                                     .Build();
            CommandLineParseResult = UninstallCommandParser.Parse(Environment.GetCommandLineArgs());
        }
예제 #23
0
        internal static RootCommand CreateRootCommand()
        {
            var root = new RootCommand("JSON .NET Global Tool");

            root.AddCommand(new MergeCommand());
            root.AddCommand(new SetCommand());
            root.AddCommand(new RemoveCommand());
            root.AddCommand(new GetCommand());

            return(root);
        }
예제 #24
0
        /// <summary>
        /// I2C EEPROM programmer with Arduino HW interface
        /// </summary>
        static void Main(string[] args)
        {
            var rootCommand = new RootCommand();

            rootCommand.AddCommand(new Identify());
            rootCommand.AddCommand(new ListSerialPorts());
            rootCommand.AddCommand(new ScanI2CDevices());
            rootCommand.AddCommand(new ReadToFile());
            rootCommand.AddCommand(new WriteFromFile());
            rootCommand.InvokeAsync(args).Wait();
        }
예제 #25
0
        static int Main(string[] args)
        {
            var rootCommand = new RootCommand();

            var showCommand = GetShowCommand();
            var syncCommand = GetSyncCommand();

            rootCommand.AddCommand(showCommand);
            rootCommand.AddCommand(syncCommand);

            return(rootCommand.InvokeAsync(args).Result);
        }
예제 #26
0
        private static int Main(string[] args)
        {
            var rootCommand     = new RootCommand("The Coyote documentation generator.");
            var generateCommand = CreateGenerateCommand();
            var mergeCommand    = CreateMergeCommand();

            rootCommand.AddCommand(generateCommand);
            rootCommand.AddCommand(mergeCommand);
            rootCommand.TreatUnmatchedTokensAsErrors = true;

            return(rootCommand.Invoke(args));
        }
예제 #27
0
        static int Main(string[] args)
        {
            if (args.Length > 0)
            {
                AttachConsole(AttachParentProcess);
            }

            var command = new RootCommand
            {
                Handler = CommandHandler.Create(() =>
                {
                    Run(new SdkWrapperProxy(new SdkWrapper(), record: false));
                })
            };

            Command record = new Command(
                name: "record",
                description: "Record session updates and telemetry.")
            {
                Handler = CommandHandler.Create(() =>
                {
                    Run(new SdkWrapperProxy(new SdkWrapper(), record: true));
                })
            };

            command.AddCommand(record);

            Command playback = new Command(
                name: "playback",
                description: "Play back only events from the indexed session within the session log.")
            {
                new Argument <string>(
                    name: "logfile",
                    description: "The RaceAdmin session log file to play back."),
                new Option(
                    aliases: new[] { "--session", "-s" },
                    description: "Play back only events from the indexed session within the session log.")
                {
                    Argument = new Argument <int>(getDefaultValue: () => - 1)
                }
            };

            playback.Handler = CommandHandler.Create((string logfile, int session) =>
            {
                // for now assume just a filename and look for file in documents folder
                string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                BinaryReader reader  = new BinaryReader(File.Open(documentsPath + "\\" + logfile, FileMode.Open));
                Run(new SdkReplayProxy(reader, session));
            });
            command.AddCommand(playback);

            return(command.Invoke(args));
        }
예제 #28
0
        static Task <int> Main(string[] args)
        {
            var rootCommand = new RootCommand
            {
                Description = "V-Drum Explorer console interface"
            };

            rootCommand.AddCommand(ListDevicesCommand.Command);
            rootCommand.AddCommand(ImportKitCommand.Command);
            rootCommand.AddCommand(ShowKitCommand.Command);
            return(rootCommand.InvokeAsync(args));
        }
예제 #29
0
        public static int Main(string[] args)
        {
            var rootCommand = new RootCommand();

            var qtCommand = new Command(
                "--order-templates",
                description: "Order question templates"
                );

            qtCommand.AddAlias("-ot");
            qtCommand.AddArgument(new Argument <string>("question-file"));
            qtCommand.Handler = CommandHandler.Create <string>((questionFile) =>
            {
                Console.WriteLine("Ordering question templates");
                DbHandler dbHandler = new DbHandler();
                dbHandler.OrderQuestionTemplates(questionFile);
            });
            rootCommand.AddCommand(qtCommand);

            var qfCommand = new Command(
                "--templates",
                description: "JSON-file with questions"
                );

            qfCommand.AddAlias("-t");
            qfCommand.AddArgument(new Argument <string>("question-file"));
            qfCommand.Handler = CommandHandler.Create <string>((questionFile) =>
            {
                Console.WriteLine($"The given input is: {questionFile}");
                DbHandler dbHandler = new DbHandler();
                dbHandler.PopulateQuestionTemplate(questionFile);
            });
            rootCommand.AddCommand(qfCommand);

            var oqCommand = new Command(
                "--order-questions",
                description: "Order questions in given evaluation"
                );

            oqCommand.AddAlias("-oq");
            oqCommand.AddArgument(new Argument <string>("evaluation-id"));
            oqCommand.Handler = CommandHandler.Create <string>((evaluationId) =>
            {
                Console.WriteLine($"Ordering questions for evaluation: {evaluationId}");
                DbHandler dbHandler = new DbHandler();
                dbHandler.OrderQuestionsInEvaluation(evaluationId);
            });
            rootCommand.AddCommand(oqCommand);

            rootCommand.Description = "Various scripts for DB handling";

            return(rootCommand.InvokeAsync(args).Result);
        }
예제 #30
0
        public static int Run(string[] args)
        {
            var rootCommand = new RootCommand();

            rootCommand.Add(new Option <VerbosityLevel>("--verbosity", VerbosityLevel.Normal, "Output verbosity level. Allowed values are normal and diagnostic."));
            rootCommand.Add(new Option <string[]>("--trace", Array.Empty <string>(), "Output additional trace loggers specified by name."));

            var buildCommand = new Command("build", "Generates C# code, database model file and other project assets.");

            // CurrentDirectory by default, because rhetos.exe on *build* is expected to be located in NuGet package cache.
            buildCommand.Add(new Argument <DirectoryInfo>("project-root-folder", () => new DirectoryInfo(Environment.CurrentDirectory))
            {
                Description = "Project folder where csproj file is located. If not specified, current working directory is used by default."
            });
            buildCommand.Add(new Option <bool>("--msbuild-format", false, "Adjust error output format for MSBuild integration."));
            buildCommand.Handler = CommandHandler.Create((DirectoryInfo projectRootFolder, bool msbuildFormat, VerbosityLevel verbosity, string[] trace) =>
            {
                var program = new Program(verbosity, trace);
                program.SafeExecuteCommand(() => program.Build(projectRootFolder.FullName), "Build", msbuildFormat);
            });
            rootCommand.AddCommand(buildCommand);

            var dbUpdateCommand = new Command("dbupdate", "Updates the database structure and initializes the application data in the database.");

            dbUpdateCommand.Add(new Argument <FileInfo>("startup-assembly")
            {
                Description = "Startup assembly of the host application."
            });
            dbUpdateCommand.Add(new Option <bool>("--short-transactions", "Commit transaction after creating or dropping each database object."));
            dbUpdateCommand.Add(new Option <bool>("--skip-recompute", "Skip automatic update of computed data with KeepSynchronized. See output log for data that needs updating."));
            //Lack of this switch means that the dbupdate command should start the command rhetos.exe dbupdate
            //in another process with the host applications runtimeconfig.json and deps.json files
            var executeCommandInCurrentProcessOption = new Option <bool>(ExecuteCommandInCurrentProcessOptionName);

            executeCommandInCurrentProcessOption.IsHidden = true;
            dbUpdateCommand.Add(executeCommandInCurrentProcessOption);
            dbUpdateCommand.Handler =
                CommandHandler.Create((FileInfo startupAssembly, bool shortTransactions, bool skipRecompute, bool executeCommandInCurrentProcess, VerbosityLevel verbosity, string[] trace) =>
            {
                var program = new Program(verbosity, trace);
                if (executeCommandInCurrentProcess)
                {
                    return(program.SafeExecuteCommand(() => program.DbUpdate(startupAssembly.FullName, shortTransactions, skipRecompute), "DbUpdate", msBuildErrorFormat: false));
                }
                else
                {
                    return(program.InvokeDbUpdateAsExternalProcess(startupAssembly.FullName, args));
                }
            });
            rootCommand.AddCommand(dbUpdateCommand);

            return(rootCommand.Invoke(args));
        }