... | @@ -77,8 +77,44 @@ import anywave as aw |
... | @@ -77,8 +77,44 @@ import anywave as aw |
|
aw.init(sys.argv)
|
|
aw.init(sys.argv)
|
|
args = aw.get_props()
|
|
args = aw.get_props()
|
|
```
|
|
```
|
|
|
|
|
|
args is a dict containing all the properties related to AnyWave current data file and the plugin context.
|
|
args is a dict containing all the properties related to AnyWave current data file and the plugin context.
|
|
|
|
When using the Plugin Creation Assistant of AnyWave, the file is automatically created.
|
|
|
|
## Command Line
|
|
|
|
You may want your plugin to be used when AnyWave is launched using the command line.
|
|
|
|
AnyWave can run processes/plugins when launched that way:
|
|
|
|
````bash
|
|
|
|
anywave --run MyPlugin --input_file <filepath> --plugin_option1 option --plugin_option2 option ...
|
|
|
|
````
|
|
|
|
### Add a flag to desc.txt
|
|
|
|
Add or edit the following line in desc.txt:
|
|
|
|
````test
|
|
|
|
flags = CanRunFromCommandLine
|
|
|
|
````
|
|
|
|
Note that you can set several flags separating them by '**:**'
|
|
|
|
|
|
|
|
### Handle command line options
|
|
|
|
By default the plugin will have all parameters passed to anywave in the resulting args variable after the call to:
|
|
|
|
````python
|
|
|
|
import anywave as aw
|
|
|
|
import sys
|
|
|
|
aw.init(sys.argv)
|
|
|
|
|
|
|
|
args = aw.get_props();
|
|
|
|
print(args["plugin_option1"]) # value for plugin_option1 from the command line.
|
|
|
|
print(args["plugin_option2"]) # value for plugin_option2 from the command line.
|
|
|
|
````
|
|
|
|
|
|
|
|
However, this is possible only if we inform AnyWave about _plugin_option1_ and _plugin_option2_.
|
|
|
|
Otherwise, an error will occur when using the command line saying that _plugin_option1_ and _plugin_option2_ are unknown options.
|
|
|
|
|
|
|
|
#### Register specific options
|
|
|
|
To add support for specific command line option, add a file called **args.json** in the plugin folder.
|
|
|
|
This is a JSON file that must be like this:
|
|
|
|
````json
|
|
|
|
{
|
|
|
|
"Parameters" : ["plugin_option1", "plugin_option2"]
|
|
|
|
}
|
|
|
|
````
|
|
|
|
|
|
## [DEBUG Python plugin](/anywave/documentation/-/wikis/Python_debug)
|
|
## [DEBUG Python plugin](/anywave/documentation/-/wikis/Python_debug)
|
|
|
|
|
... | | ... | |