feat: command line debug option

This commit is contained in:
2026-02-26 11:15:50 +03:00
parent 2f2fc99662
commit facfc791c2
2 changed files with 31 additions and 12 deletions
+16 -11
View File
@@ -19,6 +19,21 @@ public partial class Program
{
Description = "Run in fullscreen mode"
};
private static readonly Option<bool> _debug = new Option<bool>("--debug")
{
Description = "Wait debugger attach on launch",
Hidden = true
};
private static readonly Option<RenderingMode> _renderingMode = new("--rendering-mode")
{
Description = "Rendering mode to use",
DefaultValueFactory = (_) => RenderingMode.X11
};
private static readonly Option<bool> _hideConsole = new("--hide-console")
{
Description = "Suppress console output",
DefaultValueFactory = (result) => result.GetRequiredValue(_renderingMode) == RenderingMode.DRM
};
private static readonly Command _cameraTuningCommand = new("camera-tuning")
{
@@ -80,17 +95,6 @@ public partial class Program
DefaultValueFactory = (_) => 0
};
private static readonly Option<RenderingMode> _renderingMode = new("--rendering-mode")
{
Description = "Rendering mode to use",
DefaultValueFactory = (_) => RenderingMode.X11
};
private static readonly Option<bool> _hideConsole = new("--hide-console")
{
Description = "Suppress console output",
DefaultValueFactory = (result) => result.GetRequiredValue(_renderingMode) == RenderingMode.DRM
};
public static event ConsoleCancelEventHandler? ShutdownRequested;
[STAThread]
@@ -100,6 +104,7 @@ public partial class Program
_rootCommand.SetAction(Ui);
_rootCommand.Add(_fullscreen);
_rootCommand.Add(_debug);
_rootCommand.Add(_renderingMode);
_rootCommand.Add(_hideConsole);
+15 -1
View File
@@ -22,11 +22,25 @@ public partial class Program
private static void Ui(ParseResult parseResult)
{
var builder = BuildAvaloniaApp();
var fullscreen = parseResult.GetValue(_fullscreen);
var debug = parseResult.GetValue(_debug);
var renderingMode = parseResult.GetValue(_renderingMode);
var hideConsole = parseResult.GetValue(_hideConsole);
var fullscreen = parseResult.GetValue(_fullscreen);
IsFullscreen = fullscreen;
#if DEBUG
if (debug && !System.Diagnostics.Debugger.IsAttached)
{
Console.WriteLine("Waiting debugger attach");
Console.WriteLine($"ProcessId: {Environment.ProcessPath} [{Environment.ProcessId}]");
Console.WriteLine($"Thread: {Thread.CurrentThread.Name} [{Thread.CurrentThread.ManagedThreadId}]");
while (!System.Diagnostics.Debugger.IsAttached)
Thread.Sleep(100);
System.Diagnostics.Debugger.Break();
}
#endif
if (hideConsole)
SilenceConsole();