From 5168938dad98d484d1d8ddbebebea180a64ba323 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Mon, 27 May 2024 22:34:00 +0200 Subject: [PATCH] chore(kb): start task's article --- .vscode/settings.json | 3 ++ knowledge base/task.md | 94 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 knowledge base/task.md diff --git a/.vscode/settings.json b/.vscode/settings.json index 2178140..3fbc9c9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -103,6 +103,7 @@ "clamscan", "cloudinit", "cloudquery", + "cmds", "commitlint", "commitlintrc", "compsize", @@ -270,6 +271,8 @@ "swapon", "sysrc", "systool", + "taskfile", + "taskfiles", "tclsh", "tcsh", "templating", diff --git a/knowledge base/task.md b/knowledge base/task.md new file mode 100644 index 0000000..be7695d --- /dev/null +++ b/knowledge base/task.md @@ -0,0 +1,94 @@ +# Task + +Task runner aiming to be simpler and easier to use than [GNU Make]. + +1. [TL;DR](#tldr) +1. [Further readings](#further-readings) + +## TL;DR + +Pros: + +- Taskfiles are more readable than Makefiles. + +Cons: + +- Taskfiles are written in YAML. ≈(・ཀ・≈)
+ That makes them very much similar to \[[Gitlab] / [Azure Devops]]'s pipelines, and if one has any experience with them + one knows what a pain that can be. + +Taskfiles are Task's Makefile counterpart.
+Taskfiles are written in YAML. + +Task uses `mvdan.cc/sh`, a native Go sh interpreter, to run commands.
+This allows to write sh/bash commands and have them work even where `sh` or `bash` are usually not available (e.g.: +Windows) as long as any called executable is available in `PATH`. + +
+ Installation and configuration + +```sh +# Install the executable. +brew install 'go-task' +choco install 'go-task' +sudo dnf install 'go-task' +sudo snap install 'task' --classic + +# Setup the shell's completion. +curl -fsSLo "$HOME/.config/fish/completions/task.fish" 'https://raw.githubusercontent.com/go-task/task/main/completion/fish/task.fish' +``` + +
+
+ Usage + +1. Create a file called `Taskfile.yml`, `taskfile.yml`, `Taskfile.yaml`, `taskfile.yaml`, `Taskfile.dist.yml`, + `taskfile.dist.yml`, `Taskfile.dist.yaml`, or `taskfile.dist.yaml` (ordered by priority) in the root of one's + project.
+ The `cmds` keys shall contain the commands for their own tasks: + + ```yaml + version: '3' + + tasks: + build: + cmds: + - go build -v -i main.go + + assets: + cmds: + - esbuild --bundle --minify css/index.css > public/bundle.css + ``` + +1. Run tasks by their name: + + ```sh + task assets build + ``` + + If task names are omitted, a task named `default` will be assumed. + +
+ +## Further readings + +- [Website] +- [Github] + + + + + +[azure devops]: cloud%20computing/azure/devops.md +[gitlab]: gitlab.md +[gnu make]: gnu%20userland/make.md + + + +[github]: https://github.com/go-task/task +[website]: https://taskfile.dev/ + +