Update of "plugin meta data"
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Artifact ID: | 290ace60f2d9029a705ba3d9a7ea0b1abd075795 |
---|---|
Page Name: | plugin meta data |
Date: | 2017-09-23 07:53:28 |
Original User: | mario |
Mimetype: | text/x-markdown |
Parent: | 552a69ec271d0bb26e8e8f08b864aadbc0495c94 (diff) |
Next | 6000496764c7aa81a11355c8fcf8589379ff7c86 |
plugin meta data
This spec defines a cross-language comment format for feature management.
See also https://pypi.python.org/pypi/pluginconf for a Python variant.
Its purpose for ClickyColoury is to simplify script/plugin organization (= menu structure mostly). Incidentally it enforces proper documentation, of course.
- Which is particular interesting for PowerShell, as a common scheme is largely absent. (ASCII-art code comments are somewhat rampant.)
- Like in other languages, the built-in PowerShell DocBlock scheme is
largely unsuitable: no custom fields via
Get-Help
supported. - The
menu.psm1
implements a rather crude extractor however; only looks for#
-comment blocks, not<#
(as it should) yet. Extract-PluginMeta
is public domain however.
meta block
Each tools/* script should have a top-level comment with meta fields:
# api: multitool
# version: 0.1
# title: TITLE/INFO
# description: WELL, DESCRIPTION
# type: inline
# category: BETA
# key: x5|name|dsquery
# keycode: Ctl+F7
# config: -
#
# More comments here …
This is basically a YAML structure in a comment. Which in some form or another is already used by most programmers. This spec just defines a few standard and custom fields.
<style> main .content table tr:nth-child(odd) { background: #f3f3f3; } </style>
fields
Well, most of it pretty self-explanatory:
api: | always "multitool" here (original project name) |
version: | mostly decoration |
title: | Used as button / menu inscription |
description: | short summary of what the plugin does |
type: | script execution mode (implied default is "inline") |
category: | menu category, alphanumeric only, |
hidden: | if set, omits the toolblock area |
key: | regex for the CLI mode |
keycode: | shortcut for the GUI mode (unimplemented) |
param: | additional input variable names |
status: | mostly decoration |
author: | mostly decoration |
license: | mostly decoration / unused |
src: | mostly decoration (source code origin) |
config: | list of config options (pseudo JSOL format) |
repeat: 1 | for CLI version: asks if script should be repeated |
nomenu: 1 | hide menut entry (see hidden: ) |
clipboard: auto | add script output to clipboard automatically (not enabled) |
shortcut: 7 | add icon to shortcut toolbar/ribbon (custom sorting) |
sort: 123 | largely unused, but can influence script ordering |
Normally the display and menu arrangement of scripts is driven by key: and title: -
both grouped by category: of course. In specific cases sort:
might be used to
override it.
type:
The execution mode influences how scripts are run:
type:inline | runs within CC output pane (default) |
type:window | starts script in standalone CLI powershell window |
type:cli | equivalent to type:window, but for the CLI version (which interprets it as "inline") |
type:init | run once during initialization |
type:init-gui | run once during GUI construction (in WPF runspace) |
type:main | internal functions (this is decoration for the modules/* |
param: extra, fields
Defines more input variables/fields. Now this is a workaround, but with interesting by-features.
- This meta field is mostly used for scripts that run in
window
/cli
mode, so the vars can be passed per cmdline. - Standard field and variable names are: machine, username, bulkcsv. Those are defined implicitly, whether you mention them or not.
- It adds text input or dropdown fields for each non-default field name.
- Comboboxes are created whenever a like-named "data/combobox.feldname.txt" file exists.
- For
inline
scripts any extra field becomes available as$extra
or$var3
etc. - The GUI
Read-Host
wrapper interprets the field names fromParam($x=(Read-Host "extravar"), …)
to return the right GUI text field value.
config:
The config:
field is the only structured plugin meta data entry. It allows to
describe/predefine some $cfg.vars
. It follows the JSOL-style scheme:
# config:
# { name: threaded, type: bool, value: 0, title: GUI runspace? }
# { name: domain, type: str, value: WORKWORK }
It's not used much, but for the configedit.ps1 script and the %APPDATA% file. Most default options are preset in the starter.ps1 still.
Purpose is to have plugins define custom global settings. Tools/scripts may use them still. (Because; why not?)
key: a1|b2|c3
The key:
field defines an entry for the CLI interface. The prompt there expects a shortcut to invoke scripts with. If a tool/ doesn't have one, it won't be available.
Mainly it just lists one or two alternatives to invoke a script:
# key: s5|start5
So the prompt would allow you to enter "s5" or "s5" for example.
Most scripts that expect input like a username or hostname can be started with "s5 localhost" or "s5 user123" as well. (The prompt supports arguments, yes.)
But back to the key: regex. You can define more complex alternatives like s5|sta?r?t|or-?else|teee+st
of course. It's sometimes convenient to add more flexibility and typo support, but avoid listing a hundred spellings or aliases.
alternative: $menu list
CC does not strictly depend on PMD comments. However, the alternative would be to manually manage a script array:
$menu = @(
@{
title = "Locked out users"
description = "do some stuff"
category = "cmd"
fn = "tools\script5.ps1'
type = "inline"
},
@{
title = "Other tool"
description = "do some stuff"
category = "extras"
fn = "tools\other_scr.ps1'
type = "inline"
},
)
Which, let's be honest, is enticing to noone.