Skip to content

Commit e3da600

Browse files
committed
Add Quiet and Driver CLI options
1 parent 98969ce commit e3da600

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

src/Options.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,19 @@ public static IEnumerable<Example> Examples
5656
[Option('e', HelpText = "Enables experimental features")]
5757
public bool Experimental { get; set; }
5858

59+
60+
/// <summary>
61+
/// Gets or sets a which driver to use.
62+
/// </summary>
63+
[Option('d', HelpText = "Driver to use. v2, v2net, v2win, WindowsDriver, CursesDriver or NetDriver",
64+
Default = "v2")]
65+
public string Driver { get; set; } = "v2";
66+
67+
68+
/// <summary>
69+
/// Gets or sets a value indicating whether to enable logging.
70+
/// </summary>
71+
[Option('q', HelpText = "Pass to suppress log generation")]
72+
public bool Quiet { get; set; }
5973
#nullable enable warnings
6074
}

src/Program.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ public static void Main(string[] args)
1919
.WithParsed<Options>(o =>
2020
{
2121
Editor.Experimental = o.Experimental;
22+
Editor.Quiet = o.Quiet;
2223

23-
Application.Init(null,"v2");
24+
Application.Init(null,o.Driver);
2425
var editor = new Editor();
2526
editor.Run(o);
2627
});

src/UI/Editor.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public class Editor : Toplevel
4848

4949
private static string _logDirectory = string.Empty;
5050

51+
/// <summary>
52+
/// True to disable logging (must be set before constructing <see cref="Editor"/>).
53+
/// </summary>
54+
public static bool Quiet = false;
55+
5156
/// <summary>
5257
/// Initializes a new instance of the <see cref="Editor"/> class.
5358
/// </summary>
@@ -56,7 +61,10 @@ public Editor()
5661
// Bug: This will have strange inheritance behavior if Editor is inherited from.
5762
this.CanFocus = true;
5863

59-
Logging.Logger = CreateLogger();
64+
if (!Quiet)
65+
{
66+
Logging.Logger = CreateLogger();
67+
}
6068

6169
try
6270
{
@@ -440,7 +448,12 @@ ________ .__ ________ .__
440448
Driver.SetAttribute(new Attribute(new Color(colorAtPoint), new Color(Color.Black)));
441449
this.AddRune(x, y, (Rune)versionLine[i]);
442450
}
443-
451+
452+
if (Quiet)
453+
{
454+
return;
455+
}
456+
444457
// Render the log directory line below the version line
445458
int logLineX = inArea.X + (inArea.Width - logLine.Length) / 2;
446459
int logLineY = versionLineY+2;
@@ -711,6 +724,7 @@ public bool HasUnsavedChanges
711724
}
712725
}
713726

727+
714728
private string GetHelpWithEmptyFormLoaded()
715729
{
716730
return $"{this.keyMap.AddView} to Add a View";

0 commit comments

Comments
 (0)