mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Return pause before exit functionality.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Aaru" type="DotNetProject" factoryName=".NET Project">
|
||||
<option name="EXE_PATH" value="$PROJECT_DIR$/Aaru/bin/Debug/net10.0/aaru" />
|
||||
<option name="PROGRAM_PARAMETERS" value="archive extract --help" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/Aaru/bin/Debug/net10.0" />
|
||||
<option name="PROGRAM_PARAMETERS" value="fs --pause --logfile mylog.log ls qcow.qc.lz" />
|
||||
<option name="WORKING_DIRECTORY" value="/mnt/AaruTests/Media image formats/QEMU/QEMU Copy On Write" />
|
||||
<option name="PASS_PARENT_ENVS" value="1" />
|
||||
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||
<option name="ENV_FILE_PATHS" value="" />
|
||||
@@ -15,7 +15,7 @@
|
||||
<option name="PROJECT_PATH" value="$PROJECT_DIR$/Aaru/Aaru.csproj" />
|
||||
<option name="PROJECT_EXE_PATH_TRACKING" value="1" />
|
||||
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
||||
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
||||
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="0" />
|
||||
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||
<option name="PROJECT_TFM" value="net10.0" />
|
||||
<method v="2">
|
||||
|
||||
@@ -19,11 +19,8 @@ public class BaseSettings : CommandSettings
|
||||
[Description("Path to log file.")]
|
||||
public string? LogFile { get; set; }
|
||||
|
||||
// TODO: Add support for this
|
||||
/*
|
||||
[CommandOption("--pause")]
|
||||
[Description("Pauses before exiting.")]
|
||||
[DefaultValue(false)]
|
||||
public bool Pause { get; init; }
|
||||
*/
|
||||
public bool Pause { get; init; }
|
||||
}
|
||||
15
Aaru/Main.cs
15
Aaru/Main.cs
@@ -61,9 +61,10 @@ namespace Aaru;
|
||||
|
||||
class MainClass
|
||||
{
|
||||
static string _assemblyCopyright;
|
||||
static string _assemblyTitle;
|
||||
static AssemblyInformationalVersionAttribute _assemblyVersion;
|
||||
static string _assemblyCopyright;
|
||||
static string _assemblyTitle;
|
||||
static AssemblyInformationalVersionAttribute _assemblyVersion;
|
||||
public static bool PauseBeforeExiting { get; set; }
|
||||
|
||||
public static async Task<int> Main([NotNull] string[] args)
|
||||
{
|
||||
@@ -396,15 +397,17 @@ class MainClass
|
||||
config.AddCommand<RemoteCommand>("remote").WithAlias("rem").WithDescription(UI.Remote_Command_Description);
|
||||
|
||||
config.SetInterceptor(new LoggingInterceptor());
|
||||
config.SetInterceptor(new PausingInterceptor());
|
||||
});
|
||||
|
||||
int ret = await app.RunAsync(args);
|
||||
|
||||
await Statistics.SaveStatsAsync();
|
||||
|
||||
// TODO: Return pause functionality
|
||||
// AaruConsole.WriteLine(UI.Press_any_key_to_exit);
|
||||
// System.Console.ReadKey();
|
||||
if(!PauseBeforeExiting) return ret;
|
||||
|
||||
AaruConsole.WriteLine(UI.Press_any_key_to_exit);
|
||||
System.Console.ReadKey();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
20
Aaru/PausingInterceptor.cs
Normal file
20
Aaru/PausingInterceptor.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Aaru.Commands;
|
||||
using Spectre.Console.Cli;
|
||||
|
||||
namespace Aaru;
|
||||
|
||||
public class PausingInterceptor : ICommandInterceptor
|
||||
{
|
||||
#region ICommandInterceptor Members
|
||||
|
||||
public void Intercept(CommandContext context, CommandSettings settings)
|
||||
{
|
||||
if(settings is not BaseSettings global) return;
|
||||
|
||||
if(global is not { Pause: true }) return;
|
||||
|
||||
MainClass.PauseBeforeExiting = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user