add environment variable form of new CLI args, update docs

This commit is contained in:
Jesse Plamondon-Willard 2022-04-09 12:03:30 -04:00
parent 283e7d1132
commit 288ef5dc07
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
3 changed files with 10 additions and 2 deletions

View File

@ -20,7 +20,6 @@
* Added `data-*` attributes to the log parser page for external tools. * Added `data-*` attributes to the log parser page for external tools.
* Fixed JSON validator showing incorrect error for update keys without a subkey. * Fixed JSON validator showing incorrect error for update keys without a subkey.
### For mod authors ### For mod authors
This is a big release that includes the new APIs planned for SMAPI 4.0.0, alongside the old ones. This is a big release that includes the new APIs planned for SMAPI 4.0.0, alongside the old ones.
@ -40,6 +39,7 @@ the C# mod that loads them is updated.
_This adds support for many previously unsupported cases: proxied interfaces in return values or input arguments, proxied enums if their values match, generic methods, and more. Existing mod APIs should work fine as-is._ _This adds support for many previously unsupported cases: proxied interfaces in return values or input arguments, proxied enums if their values match, generic methods, and more. Existing mod APIs should work fine as-is._
* Mod files loaded through SMAPI APIs (including `helper.Content.Load`) are now case-insensitive, even on Linux. * Mod files loaded through SMAPI APIs (including `helper.Content.Load`) are now case-insensitive, even on Linux.
* Other improvements: * Other improvements:
* Added [command-line arguments](technical/smapi.md#command-line-arguments) to toggle developer mode (thanks to Tondorian!).
* Added `IContentPack.ModContent` property. * Added `IContentPack.ModContent` property.
* Added `Constants.ContentPath`. * Added `Constants.ContentPath`.
* Added `IAssetName` fields to the info received by `IAssetEditor` and `IAssetLoader` methods. * Added `IAssetName` fields to the info received by `IAssetEditor` and `IAssetLoader` methods.

View File

@ -33,11 +33,12 @@ argument | purpose
`--uninstall` | Preselects the uninstall action, skipping the prompt asking what the user wants to do. `--uninstall` | Preselects the uninstall action, skipping the prompt asking what the user wants to do.
`--game-path "path"` | Specifies the full path to the folder containing the Stardew Valley executable, skipping automatic detection and any prompt to choose a path. If the path is not valid, the installer displays an error. `--game-path "path"` | Specifies the full path to the folder containing the Stardew Valley executable, skipping automatic detection and any prompt to choose a path. If the path is not valid, the installer displays an error.
SMAPI itself recognises two arguments **on Windows only**, but these are intended for internal use SMAPI itself recognises five arguments **on Windows only**, but these are intended for internal use
or testing and may change without warning. On Linux/macOS, see _environment variables_ below. or testing and may change without warning. On Linux/macOS, see _environment variables_ below.
argument | purpose argument | purpose
-------- | ------- -------- | -------
`--developer-mode`<br />`--developer-mode-off` | Enable or disable features intended for mod developers. Currently this only makes `TRACE`-level messages appear in the console.
`--no-terminal` | The SMAPI launcher won't try to open a terminal window, and SMAPI won't log anything to the console. (Messages will still be written to the log file.) `--no-terminal` | The SMAPI launcher won't try to open a terminal window, and SMAPI won't log anything to the console. (Messages will still be written to the log file.)
`--use-current-shell` | The SMAPI launcher won't try to open a terminal window, but SMAPI will still log to the console. (Messages will still be written to the log file.) `--use-current-shell` | The SMAPI launcher won't try to open a terminal window, but SMAPI will still log to the console. (Messages will still be written to the log file.)
`--mods-path` | The path to search for mods, if not the standard `Mods` folder. This can be a path relative to the game folder (like `--mods-path "Mods (test)"`) or an absolute path. `--mods-path` | The path to search for mods, if not the standard `Mods` folder. This can be a path relative to the game folder (like `--mods-path "Mods (test)"`) or an absolute path.
@ -49,6 +50,7 @@ can set temporary environment variables instead. For example:
environment variable | purpose environment variable | purpose
-------------------- | ------- -------------------- | -------
`SMAPI_DEVELOPER_MODE` | Equivalent to `--developer-mode` and `--developer-mode-off` above. The value must be `true` or `false`.
`SMAPI_MODS_PATH` | Equivalent to `--mods-path` above. `SMAPI_MODS_PATH` | Equivalent to `--mods-path` above.
`SMAPI_NO_TERMINAL` | Equivalent to `--no-terminal` above. `SMAPI_NO_TERMINAL` | Equivalent to `--no-terminal` above.
`SMAPI_USE_CURRENT_SHELL` | Equivalent to `--use-current-shell` above. `SMAPI_USE_CURRENT_SHELL` | Equivalent to `--use-current-shell` above.

View File

@ -200,6 +200,12 @@ namespace StardewModdingAPI
// get from environment variables // get from environment variables
if (string.IsNullOrWhiteSpace(rawModsPath)) if (string.IsNullOrWhiteSpace(rawModsPath))
rawModsPath = Environment.GetEnvironmentVariable("SMAPI_MODS_PATH"); rawModsPath = Environment.GetEnvironmentVariable("SMAPI_MODS_PATH");
if (developerMode is null)
{
string rawDeveloperMode = Environment.GetEnvironmentVariable("SMAPI_DEVELOPER_MODE");
if (rawDeveloperMode != null)
developerMode = bool.Parse(rawDeveloperMode);
}
// normalize // normalize
modsPath = !string.IsNullOrWhiteSpace(rawModsPath) modsPath = !string.IsNullOrWhiteSpace(rawModsPath)