public override void Configure(CommandLineApplication command) { command.FullName = Resources.DotnetEfFullName; command.AllowArgumentSeparator = true; var options = new ProjectOptions(); options.Configure(command); _project = options.Project; _startupProject = options.StartupProject; _framework = options.Framework; _configuration = options.Configuration; _runtime = options.Runtime; _msbuildprojectextensionspath = options.MSBuildProjectExtensionsPath; _noBuild = options.NoBuild; command.VersionOption("--version", GetVersion); _help = command.Option("-h|--help", description: null); _args = command.RemainingArguments; _applicationArgs = command.ApplicationArguments; base.Configure(command); _command = command; }
// 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.DbContextScriptDescription; _output = command.Option("-o|--output <FILE>", Resources.OutputDescription); base.Configure(command); }
public override void Configure(CommandLineApplication command) { command.Description = Resources.DbContextInfoDescription; _json = Json.ConfigureOption(command); base.Configure(command); }
public override void Configure(CommandLineApplication command) { command.Description = Resources.DbContextOptimizeDescription; _outputDir = command.Option("-o|--output-dir <PATH>", Resources.OutputDirDescription); _namespace = command.Option("-n|--namespace <NAMESPACE>", Resources.NamespaceDescription); base.Configure(command); }
public override void Configure(CommandLineApplication command) { command.Description = Resources.DatabaseDropDescription; _force = command.Option("-f|--force", Resources.DatabaseDropForceDescription); _dryRun = command.Option("--dry-run", Resources.DatabaseDropDryRunDescription); base.Configure(command); }
public override void Configure(CommandLineApplication command) { command.Description = Resources.MigrationsRemoveDescription; _force = command.Option("-f|--force", Resources.MigrationsRemoveForceDescription); _json = Json.ConfigureOption(command); base.Configure(command); }
public void Configure(CommandLineApplication command) { Project = command.Option("-p|--project <PROJECT>", Resources.ProjectDescription); StartupProject = command.Option("-s|--startup-project <PROJECT>", Resources.StartupProjectDescription); Framework = command.Option("--framework <FRAMEWORK>", Resources.FrameworkDescription); Configuration = command.Option("--configuration <CONFIGURATION>", Resources.ConfigurationDescription); Runtime = command.Option("--runtime <RUNTIME_IDENTIFIER>", Resources.RuntimeDescription); MSBuildProjectExtensionsPath = command.Option("--msbuildprojectextensionspath <PATH>", Resources.ProjectExtensionsDescription); NoBuild = command.Option("--no-build", Resources.NoBuildDescription); }
public override void Configure(CommandLineApplication command) { command.Description = Resources.MigrationsListDescription; _connection = command.Option("--connection <CONNECTION>", Resources.DbContextConnectionDescription); _noConnect = command.Option("--no-connect", Resources.NoConnectDescription); _json = Json.ConfigureOption(command); base.Configure(command); }
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.MigrationsBundleDescription; // TODO: --no-self-contained (after matching the startup project) _selfContained = command.Option("--self-contained", Resources.SelfContainedDescription); _runtime = command.Option("-r|--runtime <RUNTIME_IDENTIFIER>", Resources.RuntimeDescription); _configuration = command.Option("--configuration <CONFIGURATION>", Resources.ConfigurationDescription); base.Configure(command); }
public override void Configure(CommandLineApplication command) { command.Description = Resources.MigrationsBundleDescription; _output = command.Option("-o|--output <FILE>", Resources.MigrationsBundleOutputDescription); _force = command.Option("-f|--force", Resources.DbContextScaffoldForceDescription); _selfContained = command.Option("--self-contained", Resources.SelfContainedDescription); _runtime = command.Option("-r|--target-runtime <RUNTIME_IDENTIFIER>", Resources.MigrationsBundleRuntimeDescription); 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 override void Configure(CommandLineApplication command) { command.AllowArgumentSeparator = true; _assembly = command.Option("-a|--assembly <PATH>", Resources.AssemblyDescription); _startupAssembly = command.Option("-s|--startup-assembly <PATH>", Resources.StartupAssemblyDescription); _dataDir = command.Option("--data-dir <PATH>", Resources.DataDirDescription); _projectDir = command.Option("--project-dir <PATH>", Resources.ProjectDirDescription); _rootNamespace = command.Option("--root-namespace <NAMESPACE>", Resources.RootNamespaceDescription); _language = command.Option("--language <LANGUAGE>", Resources.LanguageDescription); WorkingDir = command.Option("--working-dir <PATH>", Resources.WorkingDirDescription); base.Configure(command); }
public void OptionValueMustBeProvided() { CommandOption?first = null; var app = new CommandLineApplication(); app.Command("test", c => { first = c.Option("--first <NAME>", "First argument", CommandOptionType.SingleValue); c.OnExecute(() => 0); }); var ex = Assert.ThrowsAny <CommandParsingException>(() => app.Execute("test", "--first")); Assert.Contains($"Missing value for option '{first?.LongName}'", ex.Message); }
public void ShortNamesMayBeDefined() { CommandOption?first = null; CommandOption?second = null; var app = new CommandLineApplication(); app.Command("test", c => { first = c.Option("-1 --first <NAME>", "First argument", CommandOptionType.SingleValue); second = c.Option("-2 --second <NAME>", "Second argument", CommandOptionType.SingleValue); c.OnExecute(() => 0); }); app.Execute("test", "-1=one", "-2", "two"); Assert.Equal("one", first?.Values[0]); Assert.Equal("two", second?.Values[0]); }
public override void Configure(CommandLineApplication command) { command.AllowArgumentSeparator = true; Assembly = command.Option("-a|--assembly <PATH>", Resources.AssemblyDescription); Project = command.Option("--project <PATH>", Resources.ProjectDescription); StartupAssembly = command.Option("-s|--startup-assembly <PATH>", Resources.StartupAssemblyDescription); StartupProject = command.Option("--startup-project <PATH>", Resources.StartupProjectDescription); _dataDir = command.Option("--data-dir <PATH>", Resources.DataDirDescription); _projectDir = command.Option("--project-dir <PATH>", Resources.ProjectDirDescription); _rootNamespace = command.Option("--root-namespace <NAMESPACE>", Resources.RootNamespaceDescription); _language = command.Option("--language <LANGUAGE>", Resources.LanguageDescription); _nullable = command.Option("--nullable", Resources.NullableDescription); WorkingDir = command.Option("--working-dir <PATH>", Resources.WorkingDirDescription); Framework = command.Option("--framework <FRAMEWORK>", Resources.FrameworkDescription); Configuration = command.Option("--configuration <CONFIGURATION>", Resources.ConfigurationDescription); base.Configure(command); }
public void OptionsWithSameName() { var app = new CommandLineApplication(); var top = app.Option("-a|--always", "Top-level", CommandOptionType.SingleValue, inherited: false); CommandOption?nested = null; app.Command("subcmd", c => { nested = c.Option("-a|--ask", "Nested", CommandOptionType.SingleValue); }); app.Execute("-a", "top"); Assert.Equal("top", top.Value()); Assert.Null(nested?.Value()); top.Values.Clear(); app.Execute("subcmd", "-a", "nested"); Assert.Null(top.Value()); Assert.Equal("nested", nested?.Value()); }
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); }
public override void Configure(CommandLineApplication command) { Context = command.Option("-c|--context <DBCONTEXT>", Resources.ContextDescription); base.Configure(command); }
private ParseOptionResult ParseOption( bool isLongOption, CommandLineApplication command, string[] args, ref int index, out CommandOption?option) { option = null; var result = ParseOptionResult.Succeeded; var arg = args[index]; var optionPrefixLength = isLongOption ? 2 : 1; var optionComponents = arg.Substring(optionPrefixLength).Split(new[] { ':', '=' }, 2); var optionName = optionComponents[0]; if (isLongOption) { option = command.Options.SingleOrDefault( opt => string.Equals(opt.LongName, optionName, StringComparison.Ordinal)); } else { option = command.Options.SingleOrDefault( opt => string.Equals(opt.ShortName, optionName, StringComparison.Ordinal)); if (option == null) { option = command.Options.SingleOrDefault( opt => string.Equals(opt.SymbolName, optionName, StringComparison.Ordinal)); } } if (option == null) { if (isLongOption && string.IsNullOrEmpty(optionName) && command.AllowArgumentSeparator) { // a stand-alone "--" is the argument separator, so skip it and // handle the rest of the args as application args for (index++; index < args.Length; index++) { command.ApplicationArguments.Add(args[index]); } } else { HandleUnexpectedArg(command, args, index, argTypeName: "option"); } result = ParseOptionResult.UnexpectedArgs; } else if (command.OptionHelp == option) { result = ParseOptionResult.ShowHelp; } else if (command.OptionVersion == option) { result = ParseOptionResult.ShowVersion; } else { if (optionComponents.Length == 2) { if (!option.TryParse(optionComponents[1])) { command.ShowHint(); throw new CommandParsingException( command, $"Unexpected value '{optionComponents[1]}' for option '{optionName}'"); } } else { if (option.OptionType == CommandOptionType.NoValue || option.OptionType == CommandOptionType.BoolValue) { // No value is needed for this option option.TryParse(null); } else { index++; arg = args[index]; if (!option.TryParse(arg)) { command.ShowHint(); throw new CommandParsingException(command, $"Unexpected value '{arg}' for option '{optionName}'"); } } } } return(result); }
/// <summary> /// Creates a new instance of <see cref="ValidationBuilder"/> for a given <see cref="CommandOption"/>. /// </summary> /// <param name="option">The option.</param> public ValidationBuilder(CommandOption option) { _option = option ?? throw new ArgumentNullException(nameof(option)); }
/// <inheritdoc/> protected override void OnBeforeExecute(CommandLineApplication app) { _cmdArg = app.Argument <CommandType>("command", "Execution command type.", false).IsRequired(); _x2yOpt = app.Option("-x2y|--xml-to-yaml", "Convert the XML configuration into YAML equivalent (will not codegen).", CommandOptionType.NoValue); }