Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
testing cmd.io stuff
#!/bin/bash
user=${1:-chiefy}
hostname=localhost
port=2223
ssh="ssh ${user}@${hostname} -p ${port}"
cmd_name=tester
test_cmd=$(cat <<'EOD'
#!cmd.io alpine bash
#!/bin/bash
echo
env
echo
i=1
echo "args:"; for arg in $@; do printf "${i}-${arg} "; i=$((i+1)); done; echo
EOD
)
${ssh} :rm ${cmd_name}
echo "${test_cmd}"|${ssh} :create ${cmd_name}
token=$(${ssh} :tokens new ${cmd_name})
${ssh} :access ${cmd_name} grant ${token}
echo
echo "no args -----------------------------------"
curl -sS "http://${token}@localhost:8080/run/${user}/${cmd_name}"
echo "-------------------------------------------"
echo
echo "args query --------------------------------"
curl -sS "http://${token}@localhost:8080/run/${user}/${cmd_name}?args=hi%20how+yes%20asdf+some+other%20ones"
echo "-------------------------------------------"
echo
echo "non-args query ----------------------------"
curl -sS "http://${token}@localhost:8080/run/${user}/${cmd_name}?val=true&something=else&whatever=false+maybe"
echo "-------------------------------------------"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.