Ensure first-time setup is invoked even when another command is requested. Fixes #563

This commit is contained in:
2021-06-04 18:27:01 +01:00
parent 24baa7e69a
commit 4eb8bb3a08
2 changed files with 21 additions and 27 deletions

View File

@@ -41,31 +41,24 @@ namespace Aaru.Commands
{
internal sealed class ConfigureCommand : Command
{
readonly bool _autoCall;
readonly bool _gdprChange;
public ConfigureCommand(bool gdprChange, bool autoCall) : base("configure",
"Configures user settings and statistics.")
{
_gdprChange = gdprChange;
_autoCall = autoCall;
public ConfigureCommand() : base("configure", "Configures user settings and statistics.") =>
Handler = CommandHandler.Create((Func<bool, bool, int>)Invoke);
}
int Invoke(bool debug, bool verbose)
{
if(!_autoCall)
{
MainClass.PrintCopyright();
MainClass.PrintCopyright();
if(debug)
AaruConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(debug)
AaruConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(verbose)
AaruConsole.VerboseWriteLineEvent += System.Console.WriteLine;
}
if(verbose)
AaruConsole.VerboseWriteLineEvent += System.Console.WriteLine;
return DoConfigure(false);
}
internal int DoConfigure(bool _gdprChange)
{
if(_gdprChange)
{
AaruConsole.

View File

@@ -38,12 +38,12 @@ using System.Linq;
using System.Reflection;
using System.Text;
using Aaru.Commands;
using Aaru.Commands.Archive;
using Aaru.Commands.Database;
using Aaru.Commands.Device;
using Aaru.Commands.Filesystem;
using Aaru.Commands.Image;
using Aaru.Commands.Media;
using Aaru.Commands.Archive;
using Aaru.Console;
using Aaru.Core;
using Aaru.Database;
@@ -116,8 +116,8 @@ namespace Aaru
a.Bus
}).Where(a => a.Count() > 1).Distinct().Select(a => a.Key))
ctx.RemoveRange(ctx.SeenDevices!.
Where(d => d.Manufacturer == duplicate.Manufacturer && d.Model == duplicate.Model &&
d.Revision == duplicate.Revision && d.Bus == duplicate.Bus).Skip(1));
Where(d => d.Manufacturer == duplicate.Manufacturer && d.Model == duplicate.Model &&
d.Revision == duplicate.Revision && d.Bus == duplicate.Bus).Skip(1));
// Remove nulls
ctx.RemoveRange(ctx.SeenDevices!.Where(d => d.Manufacturer == null && d.Model == null &&
@@ -152,9 +152,10 @@ namespace Aaru
UpdateCommand.DoUpdate(true);
}
if((args.Length < 1 || args[0].ToLowerInvariant() != "gui") &&
Settings.Settings.Current.GdprCompliance < DicSettings.GDPR_LEVEL)
new ConfigureCommand(true, true).Invoke(args);
if((args.Length < 1 || args[0].ToLowerInvariant() != "gui") &&
Settings.Settings.Current.GdprCompliance < DicSettings.GDPR_LEVEL &&
args[0].ToLowerInvariant() != "configure")
new ConfigureCommand().DoConfigure(true);
Statistics.LoadStats();
@@ -175,7 +176,7 @@ namespace Aaru
}, "Shows debug output from plugins.")
{
Argument = new Argument<bool>(() => false)
},
}
};
rootCommand.Description =
@@ -188,7 +189,7 @@ namespace Aaru
rootCommand.AddCommand(new MediaFamily());
rootCommand.AddCommand(new ArchiveFamily());
rootCommand.AddCommand(new ConfigureCommand(false, false));
rootCommand.AddCommand(new ConfigureCommand());
rootCommand.AddCommand(new FormatsCommand());
rootCommand.AddCommand(new ListEncodingsCommand());
rootCommand.AddCommand(new ListNamespacesCommand());
@@ -208,4 +209,4 @@ namespace Aaru
AaruConsole.WriteLine();
}
}
}
}