Adding a new script is often pretty easy. It needs a bare minimum comment block however to get picked up:
Create an .ps1 file (UTF-8) like that:
# api: multitool # title: my script # description: does all the things.. # type: inline # category: beta # # Some basic explanation here. Param( $username = (Read-Host"username") ) Write-Host "username is '$username'" Write-Host "1+2 is $(1+2)"
And that's mostly it.
Most code that's valid in a console script would work in the GUI.
Write-Host ain't bad
You've probably read that elsewhere. And while there's some truth to
Write-Host not being your best friend; context is key, generalizations are not.
Libraries and reusable code should obviously avoid direct screen output. But you know, at some point some things do need to be written out.
Interestingly Write-Host is pretty much a no-brainer for this GUI. A simple alias already does the trick, and allows to send colorized output to the screen. (The Write-Host/Read-Host aliases are basically a poor mans Powershell Host.)
Param / Read-Host
Now the Param() section is redundant for the GUI version, as
$username are defined by default.
This is mainly necessary for the CLI version - and to allow all scripts to run standalone still.
Read-Host within the script
Care should be taken not to overuse
Read-Host. The GUI catches it, but shows up an inconvenient popup.
While standalone scripts may sometimes derail into a text adventure-style game, the ClickyColoury tools/ are meant to do one thing, and one thing mostly.
Thus too much interaction should be avoided for the current implementation. (A proper WPF input method and more convenient startup prepatation are planned.)
Category, version, etc.
Add more description fields as you go along. It usually makes sense to have a version: for each independent tool - even if it's already under version control. Because, why not?
Just because scripts are minor parts, does not mean they're not significant enough to get documented.
Obviously the category: is quite essential for CC, as it decided where scripts show up in the GUI.
Other meta fields can be set to influence shortcuts, CLI key bindings, input parameters, and GUI behaviour.