Update README.md

This commit is contained in:
David Maisonave
2024-08-06 02:59:56 -04:00
committed by GitHub
parent a830029cc1
commit 4d0cb21648

View File

@@ -19,14 +19,36 @@ StashPluginHelper is a class that performs common implementation used in most pl
- Sets RUNNING_IN_COMMAND_LINE_MODE to True if detects multiple arguments - Sets RUNNING_IN_COMMAND_LINE_MODE to True if detects multiple arguments
- Sets CALLED_AS_STASH_PLUGIN to True if it's able to read from STDIN_READ - Sets CALLED_AS_STASH_PLUGIN to True if it's able to read from STDIN_READ
### Using StashPluginHelper ### StashPluginHelper Usage
from filemonitor_config import config #### Example #1
- All the arguments for StashPluginHelper class are optional.
- It can be called with no arguments if the plugin has NO UI settings and NO associated (*_config.py) file.
``` python
from StashPluginHelper import StashPluginHelper
plugin = StashPluginHelper()
plugin.Trace() # Trace command which logs out only when DEBUG_TRACING is enabled, and by default only logs to plugin log file.
```
#### Example #2
- This is an example for a plugin that has UI settings and settings from MyPlugin_config.py file.
``` python
from StashPluginHelper import StashPluginHelper
from MyPlugin_config import config
settings = { settings = {
"recursiveDisabled": False, "enableFooFoo": False,
"zzdebugTracing": False, "zzdebugTracing": False,
"zzdryRun": False, "zzdryRun": False,
} }
plugin = StashPluginHelper(settings=settings, config=config) plugin = StashPluginHelper(settings=settings, config=config)
fooFoo = plugin.pluginSettings["enableFooFoo"] # Gets plugin UI setting named enableFooFoo
yetAnotherSetting = plugin.pluginConfig["someSettingName"] # Gets setting from MyPlugin_config.py
plugin.Log(f"FooFoo = {FooFoo}") # By default, logging level is INFO, and output goes to the console and plugin log file.
plugin.Trace(f"plugin.PLUGIN_TASK_NAME = {plugin.PLUGIN_TASK_NAME}") # logs out only when DEBUG_TRACING is enabled
```
### Requirements ### Requirements
`pip install stashapp-tools --upgrade` `pip install stashapp-tools --upgrade`