Fix GDPR questions and first configuration when the first invocation is calling a command.

This commit is contained in:
2019-01-19 15:14:54 +00:00
parent 3580dd1044
commit cc90fa4ef4
2 changed files with 23 additions and 17 deletions

View File

@@ -42,11 +42,14 @@ namespace DiscImageChef.Commands
class ConfigureCommand : Command
{
readonly bool gdprChange;
bool autoCall;
bool showHelp;
public ConfigureCommand(bool gdprChange) : base("configure", "Configures user settings and statistics.")
public ConfigureCommand(bool gdprChange, bool autoCall) : base("configure",
"Configures user settings and statistics.")
{
this.gdprChange = gdprChange;
this.autoCall = autoCall;
Options = new OptionSet
{
$"{MainClass.AssemblyTitle} {MainClass.AssemblyVersion?.InformationalVersion}",
@@ -61,22 +64,25 @@ namespace DiscImageChef.Commands
public override int Invoke(IEnumerable<string> arguments)
{
List<string> extra = Options.Parse(arguments);
if(showHelp)
if(!autoCall)
{
Options.WriteOptionDescriptions(CommandSet.Out);
return (int)ErrorNumber.HelpRequested;
}
List<string> extra = Options.Parse(arguments);
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
if(showHelp)
{
Options.WriteOptionDescriptions(CommandSet.Out);
return (int)ErrorNumber.HelpRequested;
}
if(extra.Count != 0)
{
DicConsole.ErrorWriteLine("Too many arguments.");
return (int)ErrorNumber.UnexpectedArgumentCount;
MainClass.PrintCopyright();
if(MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
if(extra.Count != 0)
{
DicConsole.ErrorWriteLine("Too many arguments.");
return (int)ErrorNumber.UnexpectedArgumentCount;
}
}
if(gdprChange)

View File

@@ -79,7 +79,7 @@ namespace DiscImageChef
if(!File.Exists(Settings.Settings.MasterDbPath))
{
masterDbUpdate = true;
UpdateCommand.DoUpdate(masterDbUpdate);
UpdateCommand.DoUpdate(true);
}
DicContext mctx = DicContext.Create(Settings.Settings.MasterDbPath);
@@ -88,7 +88,7 @@ namespace DiscImageChef
if((args.Length < 1 || args[0].ToLowerInvariant() != "gui") &&
Settings.Settings.Current.GdprCompliance < DicSettings.GdprLevel)
new ConfigureCommand(true).Invoke(args);
new ConfigureCommand(true, true).Invoke(args);
Statistics.LoadStats();
if(Settings.Settings.Current.Stats != null && Settings.Settings.Current.Stats.ShareStats)
Task.Run(() => { Statistics.SubmitStats(); });
@@ -111,7 +111,7 @@ namespace DiscImageChef
new BenchmarkCommand(),
new ChecksumCommand(),
new CompareCommand(),
new ConfigureCommand(false),
new ConfigureCommand(false, false),
new ConvertImageCommand(),
new CreateSidecarCommand(),
new DecodeCommand()