Skip to content

task-tuiでGo-taskのTaskfile.ymlをTUIから実行する

TaskではタスクをTaskfile.ymlファイルに定義します。これをTUIから実行出来るツールとしてtask-tuiというものがあります。実際に使ってみたのですが「AliasやDescriptionを表示出来ない」ようで、あまり使い勝手が良いとは感じませんでした。折角試したのでインストール手順をメモしておきます。

インストール

今回はLinuxにインストールしました。

amd64
curl -LO https://github.com/aleksandersh/task-tui/releases/download/v1.3.0/task-tui_linux_amd64.tar.gz
tar -xzf task-tui_linux_amd64.tar.gz -C /usr/local/bin task-tui
arm64
curl -LO https://github.com/aleksandersh/task-tui/releases/download/v1.3.0/task-tui_linux_arm64.tar.gz
tar -xzf task-tui_linux_arm64.tar.gz -C /usr/local/bin task-tui

実行例

以下の内容でサンプル用のTaskfile.ymlを作成します。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
version: '3'

# 変数の定義(プロジェクト全体で使い回せます)
vars:
  BINARY_NAME: my-awesome-app
  BUILD_DIR: dist

tasks:
  # 1. ビルドタスク
  build:
    desc: アプリケーションをコンパイルします
    cmds:
      - mkdir -p {{.BUILD_DIR}}
      - go build -o {{.BUILD_DIR}}/{{.BINARY_NAME}} main.go
    sources:
      - "**/*.go"
    generates:
      - "{{.BUILD_DIR}}/{{.BINARY_NAME}}"

  # 2. テストタスク
  test:
    desc: すべてのテストを実行します
    cmds:
      - go test -v ./...
    silent: true # 実行コマンド自体の表示を抑え、結果だけを見やすくします

  # 3. クリーンアップタスク
  clean:
    desc: ビルド生成物を削除します
    cmds:
      - rm -rf {{.BUILD_DIR}}
      - echo "Cleanup complete!"

  # デフォルトタスク(`task` とだけ打った時に実行される)
  default:
    cmds:
      - task: test
      - task: build

task-tuiを実行します。

task-tui

以下のように表示されました。--verboseオプションも指定してみたのですが、Descriptionが表示されないようです。またAliasも表示されないので、個人的には実用性を感じられませんでした…

╔═══════════════════════════════ Taskfile ════════════════════════════════╗
║build                                                                    ║
║clean                                                                    ║
║default                                                                  ║
║test                                                                     ║
║                                                                         ║
║                                                                         ║
║                                                                         ║
║                                                                         ║
║                                                                         ║
║                                                                         ║
║                                                                         ║
║                                                                         ║
║                                                                         ║
║                                                                         ║
║                                                                         ║
║                                                                         ║
║                                                                         ║
║                                                                         ║
║                                                                         ║
╚═════════════════════════════════════════════════════════════════════════╝
 Press h to show the help page

参考

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
root@spark:/opt/openwebui# task-tui --help
task-tui v1.3.0
Usage: task-tui [flags...]

Options:
  -C, --concurrency int             (Task) Limit number of tasks to run concurrently.
  -d, --dir string                  (Task) Sets the directory in which Task will execute and look for a Taskfile.
  -n, --dry                         (Task) Compiles and prints tasks in the order that they would be run, without executing them.
      --enable-second-line          Show the description next to the task name.
  -x, --exit-code                   (Task) Pass-through the exit code of the task command.
  -f, --force                       (Task) Forces execution even when the task is up-to-date.
  -g, --global                      (Task) Runs global Taskfile, from $HOME/{T,t}askfile.{yml,yaml}.
  -h, --help                        Show task-tui usage.
      --insecure                    (Task) Forces Task to download Taskfiles over insecure connections.
  -I, --interval duration           (Task) Interval to watch for changes.
  -o, --output string               (Task) Sets output style: [interleaved|group|prefixed].
      --output-group-begin string   (Task) Message template to print before a task's grouped output.
      --output-group-end string     (Task) Message template to print after a task's grouped output.
      --output-group-error-only     (Task) Swallow output from successful tasks.
  -p, --parallel                    (Task) Executes tasks provided on command line in parallel.
  -r, --repeat                      Repeat execution of the last executed command.
  -s, --silent                      (Task) Disables echoing.
      --sort string                 (Task) Changes the order of the tasks when listed. [default|alphanumeric|none].
      --status                      (Task) Exits with non-zero exit code if any of the given tasks is not up-to-date.
  -t, --taskfile string             (Task) Choose which Taskfile to run. Defaults to "Taskfile.yml".
  -v, --verbose                     (Task) Enables verbose mode.
      --version                     Show task-tui version.
  -w, --watch                       (Task) Enables watch of the given task.
  -y, --yes                         (Task) Assume "yes" as answer to all prompts.