Skip to content

Commit

Permalink
Add a settings command (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
mthalman authored Dec 3, 2022
1 parent 37de25c commit 3c433ee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Valleysoft.Dredge/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
new ImageCommand(clientFactory),
new ManifestCommand(clientFactory),
new RepoCommand(clientFactory),
new SettingsCommand(),
new TagCommand(clientFactory),
};

Expand Down
28 changes: 28 additions & 0 deletions src/Valleysoft.Dredge/SettingsCommand.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}

0 comments on commit 3c433ee

Please sign in to comment.