aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2022-08-10 11:03:12 -0500
committerGitHub <noreply@github.com>2022-08-10 11:03:12 -0500
commite617b9bdf8d18633ec1e627b988793df161fa820 (patch)
tree3b37e7673638e644980f336278e86a1c95a556b2
parent4ba81ad7d51cdbe2a1bb9fb055f7d941c6061876 (diff)
parent7ae24ae93eb8c0c527a773acb9f4312a10f591bd (diff)
downloadslskd-e617b9bdf8d18633ec1e627b988793df161fa820.tar.gz
Merge pull request #581 from slskd/flags
Consolidate option "flags"
-rw-r--r--config/slskd.example.yml11
-rw-r--r--docs/config.md11
-rw-r--r--src/slskd/Application.cs6
-rw-r--r--src/slskd/Core/Options.cs102
-rw-r--r--src/slskd/Program.cs4
5 files changed, 79 insertions, 55 deletions
diff --git a/config/slskd.example.yml b/config/slskd.example.yml
index 16dabb22..893b2da8 100644
--- a/config/slskd.example.yml
+++ b/config/slskd.example.yml
@@ -1,11 +1,12 @@
# debug: false
-# no_logo: false
-# no_start: false
-# no_connect: false
-# no_share_scan: false
-# no_version_check: false
# remote_configuration: false
# instance_name: default
+# flags:
+# no_logo: false
+# no_start: false
+# no_connect: false
+# no_share_scan: false
+# no_version_check: false
# directories:
# incomplete: ~
# downloads: ~
diff --git a/docs/config.md b/docs/config.md
index 2254c9e2..971e8288 100644
--- a/docs/config.md
+++ b/docs/config.md
@@ -699,6 +699,17 @@ A number of additional feature flags are provided to change the runtime behavior
| `--no-share-scan` | `NO_SHARE_SCAN` | Don't perform a scan of shared directories on startup |
| `--no-version-check` | `NO_VERSION_CHECK` | Don't perform a version check on startup |
+#### **YAML**
+```yaml
+debug: false
+flags:
+ no_logo: false
+ no_start: false
+ no_connect: false
+ no_share_scan: false
+ no_version_check: false
+```
+
# Commands
The application can be run in "command mode", causing it to execute a command and then quit immediately. Available commands are:
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
@@ -136,51 +136,6 @@ namespace slskd
public bool Debug { get; init; } = Debugger.IsAttached;
/// <summary>
- /// Gets a value indicating whether the logo should be suppressed on startup.
- /// </summary>
- [Argument('n', "no-logo")]
- [EnvironmentVariable("NO_LOGO")]
- [Description("suppress logo on startup")]
- [RequiresRestart]
- public bool NoLogo { get; init; } = false;
-
- /// <summary>
- /// Gets a value indicating whether the application should quit after initialization.
- /// </summary>
- [Argument('x', "no-start")]
- [EnvironmentVariable("NO_START")]
- [Description("quit the application after initialization")]
- [RequiresRestart]
- public bool NoStart { get; init; } = false;
-
- /// <summary>
- /// Gets a value indicating whether the application should connect to the Soulseek network on startup.
- /// </summary>
- [Argument(default, "no-connect")]
- [EnvironmentVariable("NO_CONNECT")]
- [Description("do not connect to the Soulseek network on startup")]
- [RequiresRestart]
- public bool NoConnect { get; init; } = false;
-
- /// <summary>
- /// Gets a value indicating whether the application should scan shared directories on startup.
- /// </summary>
- [Argument(default, "no-share-scan")]
- [EnvironmentVariable("NO_SHARE_SCAN")]
- [Description("do not scan shares on startup")]
- [RequiresRestart]
- public bool NoShareScan { get; init; } = false;
-
- /// <summary>
- /// Gets a value indicating whether the application should check for a newer version on startup.
- /// </summary>
- [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;
-
- /// <summary>
/// Gets a value indicating whether remote configuration of options is allowed.
/// </summary>
[Argument(default, "remote-configuration")]
@@ -198,6 +153,12 @@ namespace slskd
public string InstanceName { get; init; } = "default";
/// <summary>
+ /// Gets optional flags.
+ /// </summary>
+ [Validate]
+ public FlagsOptions Flags { get; init; } = new FlagsOptions();
+
+ /// <summary>
/// Gets the path where application data is saved.
/// </summary>
[Argument(default, "app")]
@@ -285,6 +246,57 @@ namespace slskd
public IntegrationOptions Integration { get; init; } = new IntegrationOptions();
/// <summary>
+ /// Optional flags.
+ /// </summary>
+ public class FlagsOptions
+ {
+ /// <summary>
+ /// Gets a value indicating whether the logo should be suppressed on startup.
+ /// </summary>
+ [Argument('n', "no-logo")]
+ [EnvironmentVariable("NO_LOGO")]
+ [Description("suppress logo on startup")]
+ [RequiresRestart]
+ public bool NoLogo { get; init; } = false;
+
+ /// <summary>
+ /// Gets a value indicating whether the application should quit after initialization.
+ /// </summary>
+ [Argument('x', "no-start")]
+ [EnvironmentVariable("NO_START")]
+ [Description("quit the application after initialization")]
+ [RequiresRestart]
+ public bool NoStart { get; init; } = false;
+
+ /// <summary>
+ /// Gets a value indicating whether the application should connect to the Soulseek network on startup.
+ /// </summary>
+ [Argument(default, "no-connect")]
+ [EnvironmentVariable("NO_CONNECT")]
+ [Description("do not connect to the Soulseek network on startup")]
+ [RequiresRestart]
+ public bool NoConnect { get; init; } = false;
+
+ /// <summary>
+ /// Gets a value indicating whether the application should scan shared directories on startup.
+ /// </summary>
+ [Argument(default, "no-share-scan")]
+ [EnvironmentVariable("NO_SHARE_SCAN")]
+ [Description("do not scan shares on startup")]
+ [RequiresRestart]
+ public bool NoShareScan { get; init; } = false;
+
+ /// <summary>
+ /// Gets a value indicating whether the application should check for a newer version on startup.
+ /// </summary>
+ [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;
+ }
+
+ /// <summary>
/// Directory options.
/// </summary>
public class DirectoriesOptions : IValidatableObject
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;