Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better help (with color 😍) #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,38 @@ This repository contains the default Taskfile template for getting started in yo
#!/bin/bash
PATH=./node_modules/.bin:$PATH

function install {
###### MAIN TASKS

install() { ## install task
npm install
}

function build {
build() { ## build task
webpack
}

function start {
start() { ## start task
build # Call task dependency
python -m SimpleHTTPServer 9000
}

function test {
function test { ## test project
mocha test/**/*.js
}

###### UTILS

function default {
# Default task to execute
start
}

function help {
echo "$0 <task> <args>"
echo "Tasks:"
compgen -A function | cat -n
help() { ## print this help (default)
echo "$0 <task> <args>"
grep -E '^([a-zA-Z_-]+\(\) {.*?## .*|######* .+)$$' $0 \
| sed 's/######* \(.*\)/\n \1/g' \
| sed 's/\([a-zA-Z-]\+\)()/\1/' \
| awk 'BEGIN {FS = "{.*?## "}; {printf "\033[93m%-30s\033[0m %s\033[0m\n", $1, $2}'
}

TIMEFORMAT="Task completed in %3lR"
Expand Down Expand Up @@ -67,11 +73,12 @@ Open the `Taskfile` and add your tasks. To run tasks, use `run`:

$ run help
./Taskfile <task> <args>
Tasks:
1 build
2 build-all
3 help
Task completed in 0m0.005s
MAIN TASKS
install install task
build build task
start start task
UTILS
help print this help

## Techniques
### Arguments
Expand Down
22 changes: 14 additions & 8 deletions Taskfile.template
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
#!/bin/bash
PATH=./node_modules/.bin:$PATH

function install {
###### MAIN TASKS

install() { ## install task not implemented
echo "install task not implemented"
}

function build {
build() { ## build task not implemented
echo "build task not implemented"
}

function start {
start() { ## start task not implemented
echo "start task not implemented"
}

function default {
###### UTILS

default() {
start
}

function help {
echo "$0 <task> <args>"
echo "Tasks:"
compgen -A function | cat -n
help() { ## print this help (default)
echo "$0 <task> <args>"
grep -E '^([a-zA-Z_-]+\(\) {.*?## .*|######* .+)$$' $0 \
| sed 's/######* \(.*\)/\n \1/g' \
| sed 's/\([a-zA-Z-]\+\)()/\1/' \
| awk 'BEGIN {FS = "{.*?## "}; {printf "\033[93m%-30s\033[0m %s\033[0m\n", $1, $2}'
}

TIMEFORMAT="Task completed in %3lR"
Expand Down