From c875652725a033af20a00588f938219e83e23e6e Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Mon, 23 Mar 2026 21:12:44 -0500 Subject: [PATCH] Add Add Default Task To List All Tasks as a Taskfile TIL --- README.md | 3 +- .../add-default-task-to-list-all-tasks.md | 52 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 taskfile/add-default-task-to-list-all-tasks.md diff --git a/README.md b/README.md index fab56fc..1909562 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/). For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter). -_1764 TILs and counting..._ +_1765 TILs and counting..._ See some of the other learning resources I work on: @@ -1578,6 +1578,7 @@ If you've learned something here, support my efforts writing daily TILs by ### Taskfile +- [Add Default Task To List All Tasks](taskfile/add-default-task-to-list-all-tasks.md) - [Create Interactive Picker For Set Of Subtasks](taskfile/create-interactive-picker-for-set-of-subtasks.md) - [Run A Task If It Meets Criteria](taskfile/run-a-task-if-it-meets-criteria.md) diff --git a/taskfile/add-default-task-to-list-all-tasks.md b/taskfile/add-default-task-to-list-all-tasks.md new file mode 100644 index 0000000..14120d0 --- /dev/null +++ b/taskfile/add-default-task-to-list-all-tasks.md @@ -0,0 +1,52 @@ +# Add Default Task To List All Tasks + +One thing I like about [`just`](https://github.com/casey/just) is that if you +run `just` by itself, the default behavior is to list out all the commands it +can run. + +[Taskfile](https://github.com/go-task/task) technically does this as well, but +with a warning at the end: + +``` +❯ task +task: Available tasks for this project: +* notes: Interactive picker for notes tasks +* notes:diff: Show uncommitted changes in notes +* notes:edit: All-in-one edit, commit, and push notes +* notes:log: Show recent commit history for notes +* notes:open: Opens NOTES.md (syncs latest changes first) in default editor +* notes:push: Commit and push changes to notes submodule +* notes:status: Check status of notes submodule +* notes:sync: Sync latest changes from the notes submodule +task: Task "default" does not exist +``` + +I prefer to tidy this up a little by adding `task --list` as the _default_ in my +`Taskfile.yml`. + +```yml + default: + desc: Show available commands + cmds: + - task --list +``` + +Now when I run `task` with no arguments, I get this minutely nicer version: + +``` +❯ task +Alias tip: t +task: [default] task --list +task: Available tasks for this project: +* default: Show available commands +* notes: Interactive picker for notes tasks +* notes:diff: Show uncommitted changes in notes +* notes:edit: All-in-one edit, commit, and push notes +* notes:log: Show recent commit history for notes +* notes:open: Opens NOTES.md (syncs latest changes first) in default editor +* notes:push: Commit and push changes to notes submodule +* notes:status: Check status of notes submodule +* notes:sync: Sync latest changes from the notes submodule +``` + +Notice there is no `task: Task "default" does not exist` warning at the end.