From 3c433eec8588a4eb95297a7fcddd06ca8c6ae9c0 Mon Sep 17 00:00:00 2001 From: Matt Thalman Date: Sat, 3 Dec 2022 14:30:23 -0600 Subject: [PATCH] Add a settings command (#29) --- src/Valleysoft.Dredge/Program.cs | 1 + src/Valleysoft.Dredge/SettingsCommand.cs | 28 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/Valleysoft.Dredge/SettingsCommand.cs diff --git a/src/Valleysoft.Dredge/Program.cs b/src/Valleysoft.Dredge/Program.cs index 8c562a3..6720f70 100644 --- a/src/Valleysoft.Dredge/Program.cs +++ b/src/Valleysoft.Dredge/Program.cs @@ -7,6 +7,7 @@ new ImageCommand(clientFactory), new ManifestCommand(clientFactory), new RepoCommand(clientFactory), + new SettingsCommand(), new TagCommand(clientFactory), }; diff --git a/src/Valleysoft.Dredge/SettingsCommand.cs b/src/Valleysoft.Dredge/SettingsCommand.cs new file mode 100644 index 0000000..89a39f0 --- /dev/null +++ b/src/Valleysoft.Dredge/SettingsCommand.cs @@ -0,0 +1,28 @@ +using System.CommandLine; +using System.Diagnostics; + +namespace Valleysoft.Dredge; + +internal class SettingsCommand : Command +{ + public SettingsCommand() + : base("settings", "Opens the Dredge settings file") + { + this.SetHandler(Execute); + } + + private void Execute() + { + // Ensure the settings are loaded which creates a default settings file if necessary + Settings.Load(); + + try + { + Process.Start(new ProcessStartInfo(Settings.SettingsPath) { UseShellExecute = true }); + } + catch(Exception) + { + Console.WriteLine(Settings.SettingsPath); + } + } +}