Skip to content

Commit

Permalink
output format option
Browse files Browse the repository at this point in the history
  • Loading branch information
gicastel committed Nov 7, 2022
1 parent f4fb8e8 commit 989fc21
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/qest/Commands/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ public sealed class Settings : CommandSettings
[CommandOption("-c|--tcs <TARGETCONNECTIONSTRING>")]
public string ConnectionString { get; init; }

private List<string> AllowedOutput = new List<string>(){"console", "tree"};

[Description($"Output format: console / tree")]
[CommandOption("-o|--output <OUTPUTFORMAT>")]
[DefaultValue("console")]
public string OutputFormat { get; init; }


public override ValidationResult Validate()
{
if (Folder is null && File is null)
Expand Down Expand Up @@ -61,6 +69,9 @@ public override ValidationResult Validate()

var result = Validators.ValidateConnectionString(ConnectionString);

if (!AllowedOutput.Contains(OutputFormat))
return ValidationResult.Error($"Output format could be: {string.Join(", ", AllowedOutput)}");

return result;
}

Expand All @@ -85,7 +96,11 @@ public override async Task<int> ExecuteAsync([NotNull] CommandContext context, [
}

IVisualizer visualizer;
visualizer = new ConsoleVisualizer<MsSqlConnector>(TestCollection, settings.ConnectionString);
if (settings.OutputFormat == "tree")
visualizer = new TreeVisualizer<MsSqlConnector>(TestCollection, settings.ConnectionString);
else
visualizer = new ConsoleVisualizer<MsSqlConnector>(TestCollection, settings.ConnectionString);


int exitCode = await visualizer.RunAllAsync();
return exitCode;
Expand Down

0 comments on commit 989fc21

Please sign in to comment.