summaryrefslogtreecommitdiff
path: root/src/SMAPI/Program.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-11-03 18:24:34 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-11-03 18:24:34 -0500
commitdf7e814286641c27a64cf354c15d69ddcfae062d (patch)
treec872ee47e71f2efd7b90d45c4020872e10de71d0 /src/SMAPI/Program.cs
parentf386df7e4d245254ca46afb3d152c600fd6035f9 (diff)
downloadSMAPI-df7e814286641c27a64cf354c15d69ddcfae062d.tar.gz
SMAPI-df7e814286641c27a64cf354c15d69ddcfae062d.tar.bz2
SMAPI-df7e814286641c27a64cf354c15d69ddcfae062d.zip
add support for using environment variables instead of command-line arguments (#665)
Diffstat (limited to 'src/SMAPI/Program.cs')
-rw-r--r--src/SMAPI/Program.cs28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs
index 2d143439..05d7ff66 100644
--- a/src/SMAPI/Program.cs
+++ b/src/SMAPI/Program.cs
@@ -116,21 +116,27 @@ namespace StardewModdingAPI
/// <remarks>This method is separate from <see cref="Main"/> because that can't contain any references to assemblies loaded by <see cref="CurrentDomain_AssemblyResolve"/> (e.g. via <see cref="Constants"/>), or Mono will incorrectly show an assembly resolution error before assembly resolution is set up.</remarks>
private static void Start(string[] args)
{
- // get flags from arguments
- bool writeToConsole = !args.Contains("--no-terminal");
+ // get flags
+ bool writeToConsole = !args.Contains("--no-terminal") && Environment.GetEnvironmentVariable("SMAPI_NO_TERMINAL") == null;
- // get mods path from arguments
- string modsPath = null;
+ // get mods path
+ string modsPath;
{
+ string rawModsPath = null;
+
+ // get from command line args
int pathIndex = Array.LastIndexOf(args, "--mods-path") + 1;
if (pathIndex >= 1 && args.Length >= pathIndex)
- {
- modsPath = args[pathIndex];
- if (!string.IsNullOrWhiteSpace(modsPath) && !Path.IsPathRooted(modsPath))
- modsPath = Path.Combine(Constants.ExecutionPath, modsPath);
- }
- if (string.IsNullOrWhiteSpace(modsPath))
- modsPath = Constants.DefaultModsPath;
+ rawModsPath = args[pathIndex];
+
+ // get from environment variables
+ if (string.IsNullOrWhiteSpace(rawModsPath))
+ rawModsPath = Environment.GetEnvironmentVariable("SMAPI_MODS_PATH");
+
+ // normalise
+ modsPath = !string.IsNullOrWhiteSpace(rawModsPath)
+ ? Path.Combine(Constants.ExecutionPath, rawModsPath)
+ : Constants.DefaultModsPath;
}
// load SMAPI