You have two options:
- Use
sheesh
to produce command - Define command within a yaml
sheesh setcommand --command "hello" --script "echo 'hello'"
sheesh setflag --command "hello" --name "who" --predefined "toto,titi,tata"
sheesh setflag --command "hello" --name "nrandom" --noargs
sheesh setscript --command "hello" --script "if [ \"\$RANDOM\" = true ]; then WHO='toto';fi;echo \"hello \${WHO}\""
source <(sheesh)
- Create
.sheesh.yml
file - Launch:
source <(sheesh)
An .sheesh.yml
example producing some api call:
---
commands:
- name: api-postman
flags:
- name: stealth
description: "change User-Agent"
noarg: true
- name: token
predefined:
- "THISISAADMINTOKEN"
- "Dzdk7e0987djjdzz87dz"
- name: save
description: "file to save output"
file: true
script: |
USERAGENT="curl 2.0/7"
if [ "$STEALTH" = true ] ; then
USERAGENT="not a hacker"
fi
if [ -n "$SAVE" ];then
curl -H "User-Agent: ${USERAGENT}" -H "Authorization: Bearer ${TOKEN}" http://postman-echo.com/get > "${SAVE}"
else
curl -H "User-Agent: ${USERAGENT}" -H "Authorization: Bearer ${TOKEN}" http://postman-echo.com/get
fi
- very useful when you are testing api with
curl
- want to have command in all shell, add this to
.${SHELL}rc
:source <(sheesh --file [PATH_TO_SHEESHYAML]
)
- Only for zsh
- Use uppercase flag name in your script to use it value (
$FLAGNAME
) - No default value
- Can't use var with "-" (hence flag too)