Merge pull request #836 from Tondorian/feature/CommandLineArgs
Add command-line arguments to toggle developer mode # Conflicts: # src/SMAPI/Program.cs
This commit is contained in:
commit
283e7d1132
|
@ -173,7 +173,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>
|
||||
public SCore(string modsPath, bool writeToConsole)
|
||||
/// <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;
|
||||
|
||||
|
@ -190,6 +191,7 @@ namespace StardewModdingAPI.Framework
|
|||
this.Settings = JsonConvert.DeserializeObject<SConfig>(File.ReadAllText(Constants.ApiConfigPath));
|
||||
if (File.Exists(Constants.ApiUserConfigPath))
|
||||
JsonConvert.PopulateObject(File.ReadAllText(Constants.ApiUserConfigPath), this.Settings);
|
||||
this.Settings.DeveloperMode = developerMode ?? this.Settings.DeveloperMode;
|
||||
|
||||
this.LogManager = new LogManager(logPath: logPath, colorConfig: this.Settings.ConsoleColors, writeToConsole: writeToConsole, isVerbose: this.Settings.VerboseLogging, isDeveloperMode: this.Settings.DeveloperMode, getScreenIdForLog: this.GetScreenIdForLog);
|
||||
this.CommandManager = new CommandManager(this.Monitor);
|
||||
|
|
|
@ -181,27 +181,34 @@ namespace StardewModdingAPI
|
|||
bool writeToConsole = !args.Contains("--no-terminal") && Environment.GetEnvironmentVariable("SMAPI_NO_TERMINAL") == null;
|
||||
|
||||
// get mods path
|
||||
bool? developerMode = null;
|
||||
string modsPath;
|
||||
{
|
||||
string rawModsPath = null;
|
||||
|
||||
// get from command line args
|
||||
// get mods path from command line args
|
||||
int pathIndex = Array.LastIndexOf(args, "--mods-path") + 1;
|
||||
if (pathIndex >= 1 && args.Length >= pathIndex)
|
||||
rawModsPath = args[pathIndex];
|
||||
|
||||
// get developer mode from command line args
|
||||
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(modsPath, writeToConsole);
|
||||
using SCore core = new(modsPath, writeToConsole, developerMode);
|
||||
core.RunInteractively();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue