From 4d0cb216481b204dfed80da60e1e12e6098f6709 Mon Sep 17 00:00:00 2001 From: David Maisonave <47364845+David-Maisonave@users.noreply.github.com> Date: Tue, 6 Aug 2024 02:59:56 -0400 Subject: [PATCH] Update README.md --- StashPluginHelper/README.md | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/StashPluginHelper/README.md b/StashPluginHelper/README.md index d857a7c..bb42c85 100644 --- a/StashPluginHelper/README.md +++ b/StashPluginHelper/README.md @@ -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 CALLED_AS_STASH_PLUGIN to True if it's able to read from STDIN_READ -### Using StashPluginHelper -from filemonitor_config import config +### StashPluginHelper Usage +#### 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 = { - "recursiveDisabled": False, + "enableFooFoo": False, "zzdebugTracing": False, "zzdryRun": False, } + 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 `pip install stashapp-tools --upgrade`