You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I have been using this for quite a while and have added some of my own flare to it. I figured I would drop it off and see if you are interested.
The updated help command will check for ## Some Description on the function line and display those descriptions inline (taken and modified from a self documenting Makefile).
./Taskfile <task><args>
control_example Test different control pathways <start | stop | restart>
control_example_with_optional Test different control pathways <start | stop | restart> [service name]
debug_example This is an example of using the debug commandhelp Display usage for this application
inline_debug_example While working on a command debug is useful
no_arg No args required
one_arg One arg required
two_arg Two args required
Task completed in 0m0.002s
The debug can help when coming up with the proper settings or commands to complete the task, for example piping to tr, grep, xarg or checking bash regex in commands like FILENAME=src/test1.txt;cat ${FILENAME} > ${FILENAME/.txt/.bak}.
Let me know if there is anything I can do to help. I tried to toss in some general examples of how I am using the system right now.
I also set the commands to return an exit code if the required args are missing so you can properly chain on success, such as run one arg && run two && run three arg, the run three would not execute if run two required an arg that was missing.
#!/bin/bash
PATH=./node_modules/.bin:$PATHfunctiondebug {
echo"Stopped in REPL. Press ^D to resume, or ^C to abort."local line
whileread -r -p "> " line;doeval"$line"doneecho
}
functionno_arg { ## No args requiredecho$*
}
functionone_arg { ## One arg requiredif [ $#-ne 1 ];thenecho1>&2"Usage: $0$FUNCNAME <arg>";exit 3;fiecho$*
}
functiontwo_args { ## Two args requiredif [ $#-ne 2 ];thenecho1>&2"Usage: $0$FUNCNAME <arg> <arg>";exit 3;fiecho$*
}
functiondebug_example { ## This is an example of using the debug command
debug
}
functioncontrol_example { ## Test different control pathways <start | stop | restart>if [ $#-ne 1 ];thenecho1>&2"Usage: $0$FUNCNAME <start | stop | restart>";exit 3;fiif [ $1="start" ];thenecho"Starting..."echo$*fiif [ $1="stop" ];thenecho"Stoping...."echo$*fiif [ $1="restart" ];thenecho"Restarting..."echo$*
control_example stop && control_example start
fi
}
functioncontrol_example_with_optional { ## Test different control pathways <start | stop | restart> [service name]if [ $#-lt 1 ];thenecho1>&2"Usage: $0$FUNCNAME <start | stop | restart> [service name]";exit 3;fiif [ $1="start" ];thenecho"Starting ${2}..."echo$*fiif [ $1="stop" ];thenecho"Stoping ${2}..."echo$*fiif [ $1="restart" ];thenecho"Restarting ${2}..."echo$*
control_example_with_optional stop $2&& control_example_with_optional start $2fi
}
functioninline_debug_example { ## While working on a command debug is useful
VALUE="testing"cd src
ls
ls -alth
echo"if you type \`echo \$VALUE\` in the following REPL you will see the set value of ${VALUE}"
debug
}
functiondefault {
help
}
functionhelp { ## Display usage for this applicationecho"$0 <task> <args>"
grep -E '^function [a-zA-Z_-]+ {.*?## .*$$'$0| sed -e 's/function //'| sort | awk 'BEGIN {FS = "{.*?## "}; {printf "\033[93m%-30s\033[92m %s\033[0m\n", $1, $2}'
}
TIMEFORMAT="Task completed in %3lR"time${@:-default}```
The text was updated successfully, but these errors were encountered:
Hello, I have been using this for quite a while and have added some of my own flare to it. I figured I would drop it off and see if you are interested.
Here is an example gist I made for controlling a docker compose infrastructure: https://gist.github.com/tvalladon/e316bee4b58ca082d2190be023565949
The updated help command will check for
## Some Description
on the function line and display those descriptions inline (taken and modified from a self documenting Makefile).The debug can help when coming up with the proper settings or commands to complete the task, for example piping to tr, grep, xarg or checking bash regex in commands like
FILENAME=src/test1.txt;cat ${FILENAME} > ${FILENAME/.txt/.bak}
.Let me know if there is anything I can do to help. I tried to toss in some general examples of how I am using the system right now.
I also set the commands to return an exit code if the required args are missing so you can properly chain on success, such as
run one arg && run two && run three arg
, therun three
would not execute ifrun two
required an arg that was missing.The text was updated successfully, but these errors were encountered: