// Internal for testing internal static void Configure(CommandLineApplication app) { app.FullName = DesignStrings.BundleFullName; _migration = app.Argument("<MIGRATION>", DesignStrings.MigrationDescription); _connection = app.Option("--connection <CONNECTION>", DesignStrings.ConnectionDescription); app.VersionOption("--version", ProductInfo.GetVersion); app.HelpOption("-h|--help"); var verbose = app.Option("-v|--verbose", DesignStrings.VerboseDescription); var noColor = app.Option("--no-color", DesignStrings.NoColorDescription); var prefixOutput = app.Option("--prefix-output", DesignStrings.PrefixDescription); app.OnExecute( args => { Reporter.IsVerbose = verbose.HasValue(); Reporter.NoColor = noColor.HasValue(); Reporter.PrefixOutput = prefixOutput.HasValue(); ExecuteInternal(args); return(0); }); }
public override void Configure(CommandLineApplication command) { command.Description = Resources.DatabaseUpdateDescription; _migration = command.Argument("<MIGRATION>", Resources.MigrationDescription); _connection = command.Option("--connection <CONNECTION>", Resources.DbContextConnectionDescription); base.Configure(command); }
public override void Configure(CommandLineApplication command) { command.Description = Resources.MigrationsAddDescription; _name = command.Argument("<NAME>", Resources.MigrationNameDescription); _outputDir = command.Option("-o|--output-dir <PATH>", Resources.MigrationsOutputDirDescription); _json = Json.ConfigureOption(command); _namespace = command.Option("-n|--namespace <NAMESPACE>", Resources.MigrationsNamespaceDescription); base.Configure(command); }
public override void Configure(CommandLineApplication command) { command.Description = Resources.MigrationsScriptDescription; _from = command.Argument("<FROM>", Resources.MigrationFromDescription); _to = command.Argument("<TO>", Resources.MigrationToDescription); _output = command.Option("-o|--output <FILE>", Resources.OutputDescription); _idempotent = command.Option("-i|--idempotent", Resources.IdempotentDescription); _noTransactions = command.Option("--no-transactions", Resources.NoTransactionsDescription); base.Configure(command); }
public void MultipleValuesArgumentConsumesAllArgumentValues() { CommandArgument?argument = null; var app = new CommandLineApplication(); app.Command("test", c => { argument = c.Argument("arg", "Argument that allows multiple values", multipleValues: true); c.OnExecute(() => 0); }); app.Execute("test", "one", "two", "three", "four", "five"); Assert.Equal(new[] { "one", "two", "three", "four", "five" }, argument?.Values); }
public void ArgumentsCanBeUsedOnParentCommands() { CommandArgument?projArg = null; var app = new CommandLineApplication(); var slnArg = app.Argument("SLN_PATH", "Solution file"); app.Command("sln", c => { projArg = c.Argument("PROJ_PATH", "Project file"); }); var exitCode = app.Execute("CommandLineUtils.sln", "sln", "Tests.csproj"); Assert.Equal(0, exitCode); Assert.Equal("CommandLineUtils.sln", slnArg.Value); Assert.Equal("Tests.csproj", projArg?.Value); }
public void ExtraArgumentCausesException() { CommandArgument?first = null; CommandArgument?second = null; var app = new CommandLineApplication(); app.Command("test", c => { first = c.Argument("first", "First argument"); second = c.Argument("second", "Second argument"); c.OnExecute(() => 0); }); var ex = Assert.ThrowsAny <CommandParsingException>(() => app.Execute("test", "one", "two", "three")); Assert.Contains("three", ex.Message); }
public void RemainingArgsArePassed() { CommandArgument?first = null; CommandArgument?second = null; var app = new CommandLineApplication(); app.Command("test", c => { first = c.Argument("first", "First argument"); second = c.Argument("second", "Second argument"); c.OnExecute(() => 0); }); app.Execute("test", "one", "two"); Assert.Equal("one", first?.Value); Assert.Equal("two", second?.Value); }
public void SubcommandsCanResponseFileOptions() { var app = new CommandLineApplication(); CommandArgument?wordArgs = null; app.Command("save", c => { c.ResponseFileHandling = ResponseFileHandling.ParseArgsAsSpaceSeparated; wordArgs = c.Argument("words", "more words", multipleValues: true); }); var rspFile = CreateResponseFile(" 'lorem ipsum' ", "dolor sit amet"); app.Execute("save", "@" + rspFile); Assert.Collection(wordArgs?.Values, a => Assert.Equal("lorem ipsum", a), a => Assert.Equal("dolor", a), a => Assert.Equal("sit", a), a => Assert.Equal("amet", a)); }
public void MultipleValuesArgumentConsumesAllRemainingArgumentValues() { CommandArgument?first = null; CommandArgument?second = null; CommandArgument?third = null; var app = new CommandLineApplication(); app.Command("test", c => { first = c.Argument("first", "First argument"); second = c.Argument("second", "Second argument"); third = c.Argument("third", "Third argument that allows multiple values", multipleValues: true); c.OnExecute(() => 0); }); app.Execute("test", "one", "two", "three", "four", "five"); Assert.Equal("one", first?.Value); Assert.Equal("two", second?.Value); Assert.Equal(new[] { "three", "four", "five" }, third?.Values); }
public override void Configure(CommandLineApplication command) { command.Description = Resources.DbContextScaffoldDescription; _connection = command.Argument("<CONNECTION>", Resources.ConnectionDescription); _provider = command.Argument("<PROVIDER>", Resources.ProviderDescription); _dataAnnotations = command.Option("-d|--data-annotations", Resources.DataAnnotationsDescription); _context = command.Option("-c|--context <NAME>", Resources.ContextNameDescription); _contextDir = command.Option("--context-dir <PATH>", Resources.ContextDirDescription); _force = command.Option("-f|--force", Resources.DbContextScaffoldForceDescription); _outputDir = command.Option("-o|--output-dir <PATH>", Resources.OutputDirDescription); _schemas = command.Option("--schema <SCHEMA_NAME>...", Resources.SchemasDescription); _tables = command.Option("-t|--table <TABLE_NAME>...", Resources.TablesDescription); _useDatabaseNames = command.Option("--use-database-names", Resources.UseDatabaseNamesDescription); _json = Json.ConfigureOption(command); _namespace = command.Option("-n|--namespace <NAMESPACE>", Resources.NamespaceDescription); _contextNamespace = command.Option("--context-namespace <NAMESPACE>", Resources.ContextNamespaceDescription); _suppressOnConfiguring = command.Option("--no-onconfiguring", Resources.SuppressOnConfiguringDescription); _noPluralize = command.Option("--no-pluralize", Resources.NoPluralizeDescription); base.Configure(command); }
/// <summary> /// Creates a new instance of <see cref="ValidationBuilder"/> for a given <see cref="CommandArgument"/>. /// </summary> /// <param name="argument">The argument.</param> public ValidationBuilder(CommandArgument argument) { _argument = argument ?? throw new ArgumentNullException(nameof(argument)); }