-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cli fixes and escape hatches (#2457)
* Fix up the CLI on windows, add module support to the CLI * Add support for deleting specific items from specific groups from the CLI * Fix the CLI tests a bit * Handle other OS feedback
- Loading branch information
Showing
21 changed files
with
366 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Microsoft.Extensions.FileSystemGlobbing; | ||
using NexusMods.ProxyConsole.Abstractions.VerbDefinitions; | ||
|
||
namespace NexusMods.CLI.OptionParsers; | ||
|
||
internal class MatcherParser : IOptionParser<Matcher> | ||
{ | ||
/// <inheritdoc /> | ||
public bool TryParse(string toParse, out Matcher value, out string error) | ||
{ | ||
try | ||
{ | ||
value = new Matcher(); | ||
value.AddInclude(toParse); | ||
error = string.Empty; | ||
return true; | ||
} | ||
catch (Exception exception) | ||
{ | ||
value = null!; | ||
error = exception.Message; | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.Versioning; | ||
|
||
namespace NexusMods.App; | ||
|
||
/// <summary> | ||
/// Helpers for consoles on Windows | ||
/// </summary> | ||
[SupportedOSPlatform("windows")] | ||
public static class ConsoleHelper | ||
{ | ||
// ReSharper disable once InconsistentNaming | ||
private const int ATTACH_PARENT_PROCESS = -1; | ||
|
||
[DllImport("kernel32.dll", SetLastError = true)] | ||
private static extern bool AttachConsole(int dwProcessId); | ||
|
||
[DllImport("kernel32.dll", SetLastError = true)] | ||
private static extern bool AllocConsole(); | ||
|
||
/// <summary> | ||
/// Attempt to attach to the console, if it fails, create a new console window if desired | ||
/// </summary> | ||
/// <param name="forceNewConsoleIfNoParent">If there is no parent console, should one be created?</param> | ||
public static void EnsureConsole(bool forceNewConsoleIfNoParent = false) | ||
{ | ||
if (!AttachConsole(ATTACH_PARENT_PROCESS) && !forceNewConsoleIfNoParent) | ||
{ | ||
AllocConsole(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.