Skip to content

Commit b296557

Browse files
committed
Create initial documentation to get the idea started
0 parents  commit b296557

File tree

5 files changed

+120
-0
lines changed

5 files changed

+120
-0
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Global editor config
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
indent_style = tab
11+
indent_size = 4
12+
trim_trailing_whitespace = true

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Taskfile
2+
3+
A Taskfile adds a list of commonly used tasks in a quick overview in your CLI. Enable your users to quickly setup a
4+
project and run common tasks via super simple commands.
5+
6+
![CLI Taskfile preview](./docs/images/cli-preview.gif)
7+
8+
## Create your own taskfile
9+
10+
This project gives you a `Taskfile` base, and gives you a collection of usefull tasks to help out on your project.
11+
12+
Check [the full documentation](https://github.com/rick-nu/Taskfile).
13+
14+
## Credits
15+
16+
This Taskfile setup is based on [Adrian Cooney's Taskfile setup](https://github.com/adriancooney/Taskfile) and
17+
[Enrise](https://enrise.com) their internal implementation of the Taskfile.
18+
19+
## Contribute
20+
21+
Feel free to add your own Taskfile tasks via a PR. The more usefull tasks, the easier we make the life of other
22+
developers.

Taskfile

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
4+
# =========================================================
5+
## Documentation
6+
# =========================================================
7+
8+
function task:docs { ## Build the documentation files
9+
title "Building documentation"
10+
echo "Creating html pages from markdown..."
11+
sleep 3
12+
echo "Documentation built in dist/ folder."
13+
}
14+
15+
# =========================================================
16+
## Taskfile
17+
# =========================================================
18+
19+
BLUE=$(printf '\033[36m')
20+
YELLOW=$(printf '\033[33m')
21+
RESET=$(printf '\033[0m')
22+
23+
function title {
24+
echo -e "\n${BLUE}=>${RESET} $1\n"
25+
}
26+
27+
function banner {
28+
echo ""
29+
echo "████████╗ █████╗ ███████╗██╗ ██╗███████╗██╗██╗ ███████╗"
30+
echo "╚══██╔══╝██╔══██╗██╔════╝██║ ██╔╝██╔════╝██║██║ ██╔════╝"
31+
echo " ██║ ███████║███████╗█████╔╝ █████╗ ██║██║ █████╗"
32+
echo " ██║ ██╔══██║╚════██║██╔═██╗ ██╔══╝ ██║██║ ██╔══╝"
33+
echo " ██║ ██║ ██║███████║██║ ██╗██║ ██║███████╗███████╗"
34+
echo " ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚══════╝"
35+
}
36+
37+
function task:help { ## Show all available tasks
38+
title "Available tasks"
39+
awk 'BEGIN {FS = " { [#][#][ ]?"} /^([a-zA-Z_-]*:?.*)(\{ )?[#][#][ ]?/ \
40+
{printf "\033[33m%-34s\033[0m %s\n", $1, $2}' $0 |\
41+
sed -E "s/[#]{2,}[ ]*/${RESET}/g" |\
42+
sed -E "s/function task:*/ /g"
43+
echo -e "\n${BLUE}Usage:${RESET} $0 ${YELLOW}<task>${RESET} <args>"
44+
}
45+
46+
function task:shorthand { ## Create CLI shorthand task instead of ./Taskfile
47+
title "Creating task shorthand"
48+
if [ -f /usr/local/bin/task ]
49+
then
50+
echo "/usr/local/bin/task already exists."
51+
else
52+
echo -e "You are about to create /usr/local/bin/task that requires root permission..."
53+
sudo curl --location --silent --output /usr/local/bin/task https://bit.ly/task-shorthand
54+
sudo chmod +x /usr/local/bin/task
55+
fi
56+
echo -e "${BLUE}You can now use:${RESET} task ${YELLOW}<task>${RESET} <args>"
57+
}
58+
59+
# Execute tasks (defaults to help)
60+
banner
61+
"task:${@:-help}"

bin/task

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
# =========================================================
4+
# More info on Taskfile can be found here:
5+
# https://github.com/rick-nu/Taskfile
6+
# =========================================================
7+
8+
set -eo pipefail
9+
10+
CURRENT_DIR=$(pwd)
11+
RED=$(printf '\033[31m')
12+
RESET=$(printf '\033[0m')
13+
14+
while [ -d $CURRENT_DIR ] && [ $CURRENT_DIR != '/' ]; do
15+
cd $CURRENT_DIR
16+
17+
if [ ! -f ./Taskfile ]
18+
then
19+
echo -e "${RED}ERROR: ${RESET}./Taskfile not found in this directory."
20+
exit 1
21+
fi
22+
23+
./Taskfile $@
24+
exit $?
25+
done

docs/images/cli-preview.gif

260 KB
Loading

0 commit comments

Comments
 (0)