Programs, scripts and web requests
A tool runs one of four things. The tool editor has the first three; recipes are written by hand.
Runs a program
The safest choice. You give a program and its arguments, and it runs without a shell, so characters like ;, | or
quotes in a value are just characters:
ffmpeg -i {{ input }} -vf scale={{ width }}:-1 {{ output }}
- An argument that ends up empty is left out, which makes optional flags easy.
- On Windows, programs are found the way the command prompt finds them, so
npxandcodework by name.
Runs a script
Code in the language you choose: Shell (sh), Bash, Zsh, PowerShell, PowerShell 7, Python, JavaScript (Node.js), AppleScript, JavaScript for Automation, cmd, Ruby or Perl.
Every {{ value }} is quoted for that language automatically, so a value can't break out and run its own commands.
Don't add quotes around it yourself.
print("Hello, " + {{ name }})
is right in Python. print("Hello, {{ name }}") is wrong: the result would have extra quotes in it.
Each parameter is also available as an environment variable named SMCP_ and the parameter's name in capitals:
city becomes SMCP_CITY. That's the safest way to pass values to cmd, Ruby, Perl, or programs a script calls.
PowerShell scripts stop at the first error, and text in any language comes through correctly.
Calls a web address
A web request, for web services and APIs. Values in the address are encoded, so they can't change where the request goes:
https://api.example.com/items/{{ id }}
Choose the method (GET, POST, PUT, PATCH or DELETE), add headers, like Authorization: Bearer {{ secret.API_TOKEN }}, and a JSON body if the service needs one. A reply from a website is turned into readable
text; a JSON reply comes back as data.
Recipes
A recipe runs other tools in a row: built-in tools, your own, or tools from connected servers. See Recipes.
See also Templates and quoting and Versions for each system.