Skip to content

Commit e987427

Browse files
author
Johan van Overbeeke
committed
Remove "Remote Taskfile" type
and other findings from in-person review
1 parent 96feaa7 commit e987427

File tree

1 file changed

+21
-30
lines changed

1 file changed

+21
-30
lines changed

README.md

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -83,56 +83,47 @@ _task "$@"
8383

8484
Now after running `task shorthand`, your `task` commands will get autocompleted.
8585

86-
## Splitting Taskfiles
86+
## SubTaskfiles
8787

8888
Have a (mono)repo with multiple projects, a group of less-used or specialized tasks or just waaay to many tasks for a
89-
single Taskfile? Splitting your Taskfiles might be for you! This allows you to divide your tasks across multiple files
90-
while still (also) calling them from a single one.
89+
single Taskfile? Splitting your Taskfile might be for you! Using SubTaskfiles allows you to divide your tasks across
90+
multiple files while still calling them from a single one. Most useful for splitting off a group of tasks that can be
91+
logically grouped together, like for specific use-cases or because they are rarely used.
9192

92-
There are two types, but in both cases tasks from the secondary Taskfile are called "via" a task in the root Taskfile,
93-
like this: `./Taskfile foo <task> <args>`
93+
Example use-cases: git-hooks, frontend- / backend-specific tasks, tasks that fix (infrequently occurring) bugs, etc.
9494

95-
### Remote Taskfile
95+
SubTaskfiles can't be run directly, but are always run "via" a task in the root Taskfile, like this:
96+
`Usage: ./Taskfile foo <task> <args>`
9697

97-
This type is more verbose, but can be used on its own as well. Most useful in (mono)repos where people might be working
98-
in a subdirectory as often as on the project as a whole.
98+
### How
9999

100-
In the main Taskfile you call the secondary like any other script:
100+
Put this in the root Taskfile:
101101
```shell
102102
function task:foo { ## bar
103-
./path/to/secondary/Taskfile "${@-help}"
104-
}
105-
```
106-
107-
The secondary is just a regular Taskfile, including utilities (semi) optional ones like `task:help`, `file:ensure` and
108-
the required line with `task:"${@-help}"`at the bottom.
109-
110-
### SubTaskfile
111-
112-
This type cannot be called on its own, but has a lot less boilerplate. Most useful for splitting off a group of tasks
113-
that can be logically grouped together, for specific tasks or because they are rarely used.
103+
SUBTASKFILE_DIR="./path/to/subtaskfile/"
114104

115-
In the main Taskfile:
116-
```shell
117-
function task:foo { ## bar
118-
SUB_TASKFILE_DIR="./path/to/subtaskfile/"
119-
120-
source "$SUB_TASKFILE_DIR/Taskfile"
105+
source "$SUBTASKFILE_DIR/SubTaskfile"
121106

122107
task:"${@-_help}"
123108
}
109+
110+
# Optional: use proxy-tasks like this for tasks you want to run straight from the root Taskfile
111+
function task:baz { ## Call `foo baz` directly
112+
task:foo baz
113+
}
124114
```
125115

126-
The subTaskfile just needs to contain the tasks and sections you need, but has a few notes:
116+
Give SubTaskfile the filename `SubTaskfile`. It needs to contain only the tasks and sections you think useful (while
117+
still having access to stuff like `file:ensure` from the root Taskfile!), but it has a few notes:
127118
```shell
128-
# When you use files in the subTaskfile's directory, you need prefix them with $SUB_TASKFILE_DIR
119+
# When you refer to files in the subTaskfile's directory, you need prefix them with $SUBTASKFILE_DIR
129120
function task:call-script { ## Call a script
130-
"$SUB_TASKFILE_DIR/some-script.sh"
121+
"$SUBTASKFILE_DIR/some-script.sh"
131122
}
132123

133124
# Without this, you cannot run `./Taskfile foo` or `./Taskfile foo help`
134125
function task:_help { ## Show all available tasks
135-
task:help "$SUB_TASKFILE_DIR/Taskfile"
126+
task:help "$SUBTASKFILE_DIR/SubTaskfile"
136127
}
137128
```
138129

0 commit comments

Comments
 (0)