Trying to add new feature - System.CommandLine is confuzzeling me #238
-
I thought I'd got everything correct - but for some reason my new command line arguments are not being parsed: In //DEPENDENCY OPTIONS
private static Option<bool> AnalyzeScriptsForDependencies() =>
new(
new[] { "--dependencies", "--de" },
//getDefaultValue: () => false,
description:"AnalyzeScriptsForDependencies - This instructs grate that each script may contain dependency specifications."
); and above that I've added the option to public MigrateCommand(GrateMigrator mi) : base("Migrates the database")
{
Add(Database());
Add(ConnectionString());
Add(SqlFilesDirectory());
...
Add(AnalyzeScriptsForDependencies());
In /// <summary>
/// If specified, inform grate to look for dependencies in scripts to define the order they should be executed in
/// </summary>
public bool AnalyzeScriptsForDependencies { get; init; } = false; However my tests continue to fail in [TestCase("", false)] // default
[TestCase("--dependencies=true", true)]
[TestCase("--dependencies true", true)]
[TestCase("--dependencies", true)]
public async Task TestAnalyzeScriptsForDependencies(string args, bool expected)
{
var cfg = await ParseGrateConfiguration(args);
cfg?.AnalyzeScriptsForDependencies.Should().Be(expected);
} The first test succeeds (default to I've actually got three options in total I've added, but if I can get this first one to work, the other two should be a doddle. What on earth am I doing wrong here? Have I missed something out? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Sussed it: //DEPENDENCY OPTIONS
private static Option<bool> AnalyzeScriptsForDependencies() =>
new(
new[] { "--AnalyzeScriptsForDependencies", "--dependencies", "--de" },
description:"AnalyzeScriptsForDependencies - This instructs grate that each script may contain dependency specifications."
); The first argument (or one of the arguments at least) apparently has to match the option name. |
Beta Was this translation helpful? Give feedback.
Sussed it:
The first argument (or one of the arguments at least) apparently has to match the option name.