From 989fc21314f5ccb6cedfae351c6c1e7a205b4bf8 Mon Sep 17 00:00:00 2001 From: Giacomo Castellani Date: Mon, 7 Nov 2022 21:01:51 +0100 Subject: [PATCH] output format option --- src/qest/Commands/RunCommand.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/qest/Commands/RunCommand.cs b/src/qest/Commands/RunCommand.cs index 72d58c9..653007d 100644 --- a/src/qest/Commands/RunCommand.cs +++ b/src/qest/Commands/RunCommand.cs @@ -28,6 +28,14 @@ public sealed class Settings : CommandSettings [CommandOption("-c|--tcs ")] public string ConnectionString { get; init; } + private List AllowedOutput = new List(){"console", "tree"}; + + [Description($"Output format: console / tree")] + [CommandOption("-o|--output ")] + [DefaultValue("console")] + public string OutputFormat { get; init; } + + public override ValidationResult Validate() { if (Folder is null && File is null) @@ -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; } @@ -85,7 +96,11 @@ public override async Task ExecuteAsync([NotNull] CommandContext context, [ } IVisualizer visualizer; - visualizer = new ConsoleVisualizer(TestCollection, settings.ConnectionString); + if (settings.OutputFormat == "tree") + visualizer = new TreeVisualizer(TestCollection, settings.ConnectionString); + else + visualizer = new ConsoleVisualizer(TestCollection, settings.ConnectionString); + int exitCode = await visualizer.RunAllAsync(); return exitCode;