From 0782bd6aca1e7182077d446ffef911b7c967c514 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Wed, 10 Aug 2022 09:32:20 -0500 Subject: group flags under a new class --- src/slskd/Application.cs | 6 +-- src/slskd/Core/Options.cs | 102 ++++++++++++++++++++++++++-------------------- src/slskd/Program.cs | 4 +- 3 files changed, 62 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 44723aba..cf37d933 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -362,12 +362,12 @@ namespace slskd Log.Information($"Using Proxy {OptionsAtStartup.Soulseek.Connection.Proxy.Address}:{OptionsAtStartup.Soulseek.Connection.Proxy.Port}"); } - if (!OptionsAtStartup.NoVersionCheck) + if (!OptionsAtStartup.Flags.NoVersionCheck) { _ = CheckVersionAsync(); } - if (OptionsAtStartup.NoShareScan) + if (OptionsAtStartup.Flags.NoShareScan) { Log.Warning("Not scanning shares; 'no-share-scan' option is enabled. Search and browse results will remain disabled until a manual scan is completed."); } @@ -376,7 +376,7 @@ namespace slskd _ = Shares.StartScanAsync(); } - if (OptionsAtStartup.NoConnect) + if (OptionsAtStartup.Flags.NoConnect) { Log.Warning("Not connecting to the Soulseek server; 'no-connect' option is enabled"); } diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 197c3412..f2e89aeb 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -135,51 +135,6 @@ namespace slskd [RequiresRestart] public bool Debug { get; init; } = Debugger.IsAttached; - /// - /// Gets a value indicating whether the logo should be suppressed on startup. - /// - [Argument('n', "no-logo")] - [EnvironmentVariable("NO_LOGO")] - [Description("suppress logo on startup")] - [RequiresRestart] - public bool NoLogo { get; init; } = false; - - /// - /// Gets a value indicating whether the application should quit after initialization. - /// - [Argument('x', "no-start")] - [EnvironmentVariable("NO_START")] - [Description("quit the application after initialization")] - [RequiresRestart] - public bool NoStart { get; init; } = false; - - /// - /// Gets a value indicating whether the application should connect to the Soulseek network on startup. - /// - [Argument(default, "no-connect")] - [EnvironmentVariable("NO_CONNECT")] - [Description("do not connect to the Soulseek network on startup")] - [RequiresRestart] - public bool NoConnect { get; init; } = false; - - /// - /// Gets a value indicating whether the application should scan shared directories on startup. - /// - [Argument(default, "no-share-scan")] - [EnvironmentVariable("NO_SHARE_SCAN")] - [Description("do not scan shares on startup")] - [RequiresRestart] - public bool NoShareScan { get; init; } = false; - - /// - /// Gets a value indicating whether the application should check for a newer version on startup. - /// - [Argument(default, "no-version-check")] - [EnvironmentVariable("NO_VERSION_CHECK")] - [Description("do not check for newer version at startup")] - [RequiresRestart] - public bool NoVersionCheck { get; init; } = false; - /// /// Gets a value indicating whether remote configuration of options is allowed. /// @@ -197,6 +152,12 @@ namespace slskd [RequiresRestart] public string InstanceName { get; init; } = "default"; + /// + /// Gets optional flags. + /// + [Validate] + public FlagsOptions Flags { get; init; } = new FlagsOptions(); + /// /// Gets the path where application data is saved. /// @@ -284,6 +245,57 @@ namespace slskd [Validate] public IntegrationOptions Integration { get; init; } = new IntegrationOptions(); + /// + /// Optional flags. + /// + public class FlagsOptions + { + /// + /// Gets a value indicating whether the logo should be suppressed on startup. + /// + [Argument('n', "no-logo")] + [EnvironmentVariable("NO_LOGO")] + [Description("suppress logo on startup")] + [RequiresRestart] + public bool NoLogo { get; init; } = false; + + /// + /// Gets a value indicating whether the application should quit after initialization. + /// + [Argument('x', "no-start")] + [EnvironmentVariable("NO_START")] + [Description("quit the application after initialization")] + [RequiresRestart] + public bool NoStart { get; init; } = false; + + /// + /// Gets a value indicating whether the application should connect to the Soulseek network on startup. + /// + [Argument(default, "no-connect")] + [EnvironmentVariable("NO_CONNECT")] + [Description("do not connect to the Soulseek network on startup")] + [RequiresRestart] + public bool NoConnect { get; init; } = false; + + /// + /// Gets a value indicating whether the application should scan shared directories on startup. + /// + [Argument(default, "no-share-scan")] + [EnvironmentVariable("NO_SHARE_SCAN")] + [Description("do not scan shares on startup")] + [RequiresRestart] + public bool NoShareScan { get; init; } = false; + + /// + /// Gets a value indicating whether the application should check for a newer version on startup. + /// + [Argument(default, "no-version-check")] + [EnvironmentVariable("NO_VERSION_CHECK")] + [Description("do not check for newer version at startup")] + [RequiresRestart] + public bool NoVersionCheck { get; init; } = false; + } + /// /// Directory options. /// diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 5ed6bf80..e733c086 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -300,7 +300,7 @@ namespace slskd ConfigureGlobalLogger(); Log = Serilog.Log.ForContext(typeof(Program)); - if (!OptionsAtStartup.NoLogo) + if (!OptionsAtStartup.Flags.NoLogo) { PrintLogo(FullVersion); } @@ -385,7 +385,7 @@ namespace slskd app.ConfigureAspDotNetPipeline(); - if (OptionsAtStartup.NoStart) + if (OptionsAtStartup.Flags.NoStart) { Log.Information("Qutting because 'no-start' option is enabled"); return; -- cgit v1.2.3