simplify format for new CLI arguments
This commit is contained in:
parent
61d857c41f
commit
092f0aa4ea
|
@ -168,8 +168,8 @@ namespace StardewModdingAPI.Framework
|
|||
/// <summary>Construct an instance.</summary>
|
||||
/// <param name="modsPath">The path to search for mods.</param>
|
||||
/// <param name="writeToConsole">Whether to output log messages to the console.</param>
|
||||
/// <param name="developerModeValue">null if not modified else whether to use developer mode</param>
|
||||
public SCore(string modsPath, bool writeToConsole, bool? developerModeValue)
|
||||
/// <param name="developerMode">Whether to enable development features, or <c>null</c> to use the value from the settings file.</param>
|
||||
public SCore(string modsPath, bool writeToConsole, bool? developerMode)
|
||||
{
|
||||
SCore.Instance = this;
|
||||
|
||||
|
@ -184,12 +184,7 @@ namespace StardewModdingAPI.Framework
|
|||
|
||||
// init basics
|
||||
this.Settings = JsonConvert.DeserializeObject<SConfig>(File.ReadAllText(Constants.ApiConfigPath));
|
||||
|
||||
// temporary overwrite DeveloperMode Setting
|
||||
if (developerModeValue.HasValue)
|
||||
{
|
||||
this.Settings.DeveloperMode = developerModeValue.Value;
|
||||
}
|
||||
this.Settings.DeveloperMode = developerMode ?? this.Settings.DeveloperMode;
|
||||
|
||||
if (File.Exists(Constants.ApiUserConfigPath))
|
||||
JsonConvert.PopulateObject(File.ReadAllText(Constants.ApiUserConfigPath), this.Settings);
|
||||
|
|
|
@ -179,7 +179,7 @@ namespace StardewModdingAPI
|
|||
bool writeToConsole = !args.Contains("--no-terminal") && Environment.GetEnvironmentVariable("SMAPI_NO_TERMINAL") == null;
|
||||
|
||||
// get mods path
|
||||
bool? developerModeValue = null;
|
||||
bool? developerMode = null;
|
||||
string modsPath;
|
||||
{
|
||||
string rawModsPath = null;
|
||||
|
@ -190,31 +190,23 @@ namespace StardewModdingAPI
|
|||
rawModsPath = args[pathIndex];
|
||||
|
||||
// get developer mode from command line args
|
||||
int developerModeValueIndex = Array.LastIndexOf(args, "--developer-mode") + 1;
|
||||
if (developerModeValueIndex >= 1 && args.Length >= developerModeValueIndex)
|
||||
{
|
||||
if (args[developerModeValueIndex].ToLower().Equals("true"))
|
||||
{
|
||||
developerModeValue = true;
|
||||
}
|
||||
else if (args[developerModeValueIndex].ToLower().Equals("false"))
|
||||
{
|
||||
developerModeValue = false;
|
||||
}
|
||||
}
|
||||
if (args.Contains("--developer-mode"))
|
||||
developerMode = true;
|
||||
if (args.Contains("--developer-mode-off"))
|
||||
developerMode = false;
|
||||
|
||||
// get from environment variables
|
||||
if (string.IsNullOrWhiteSpace(rawModsPath))
|
||||
rawModsPath = Environment.GetEnvironmentVariable("SMAPI_MODS_PATH");
|
||||
|
||||
// normalise
|
||||
// normalize
|
||||
modsPath = !string.IsNullOrWhiteSpace(rawModsPath)
|
||||
? Path.Combine(Constants.GamePath, rawModsPath)
|
||||
: Constants.DefaultModsPath;
|
||||
}
|
||||
|
||||
// load SMAPI
|
||||
using SCore core = new SCore(modsPath, writeToConsole, developerModeValue);
|
||||
using SCore core = new SCore(modsPath, writeToConsole, developerMode);
|
||||
core.RunInteractively();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue