From 17b52196da946ad450a1a0fb80aa6d6920181301 Mon Sep 17 00:00:00 2001 From: VinceCabs Date: Thu, 14 Dec 2023 21:37:24 +0100 Subject: [PATCH] better help --- README.md | 33 ++++++++++++++++++++------------- Taskfile.template | 22 ++++++++++++++-------- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 970d09d..c559279 100644 --- a/README.md +++ b/README.md @@ -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 " - echo "Tasks:" - compgen -A function | cat -n +help() { ## print this help (default) + echo "$0 " + 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" @@ -67,11 +73,12 @@ Open the `Taskfile` and add your tasks. To run tasks, use `run`: $ run help ./Taskfile - 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 diff --git a/Taskfile.template b/Taskfile.template index e3e7967..87c5e3d 100755 --- a/Taskfile.template +++ b/Taskfile.template @@ -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 " - echo "Tasks:" - compgen -A function | cat -n +help() { ## print this help (default) + echo "$0 " + 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"