いろいろ備忘録日記

主に .NET とか Go とか Flutter とか Python絡みのメモを公開しています。

xc (Markdown ベースで書けるタスクランナー)

概要

面白いなって思ったので、忘れないうちにメモメモ。。。

xcfile.dev

github.com

試してみる

https://xcfile.dev/getting-started/#installation

にインストール方法が記載されています。homebrewでもscoopでもインストール出来る模様。

Goで作られているので、go install でもインストールできます。

今回は、go install で入れました。

$ go version
go version go1.20.1 linux/amd64

$ go install github.com/joerdav/xc/cmd/xc@latest
go: downloading github.com/joerdav/xc v0.0.175
go: downloading github.com/posener/complete v1.2.3
go: downloading mvdan.cc/sh/v3 v3.6.0
go: downloading github.com/hashicorp/go-multierror v1.0.0
go: downloading golang.org/x/term v0.3.0

$ xc --version
xc version: v0.0.175 (h1:P3ei9yPy4ayN1F2Zi3x6uZT/xWkLE4R1zg6kABXNr+A=)

$ xc --help
xc <task> [inputs...]
  Run a task from an xc compatible markdown file.
  If -file is not specified and no README.md is found in the current directory,
    xc will search in parent files for convenience.
  -f -file <string>
        Specify a markdown file that contains tasks (default "README.md").
  -md
        Print the markdown for a task rather than running it.
  -H -heading <string>
        Specify the heading for xc tasks. (default "Tasks")

xc
  List tasks from an xc compatible markdown file.
  If -file is not specified and no README.md is found in the current directory,
    xc will search in parent files for convenience.
  -s -short
        List task names in a short format.
  -h -help
        Print this help text.
  -f -file <string>
        Specify a markdown file that contains tasks (default "README.md").
  -H -heading <string>
        Specify the heading for xc tasks. (default "Tasks")
  -version
        Show xc version.
  -complete
        Install completion for xc.
  -uncomplete
        Uninstall completion for xc.
  -y    Don't prompt user for typing 'yes' when installing completion.

オッケイ。では、へろーワールドしてみましょう。

README.md という名前にしておくとデフォルトで検知してくれるみたいです。

## Tasks

### helloworld

Echo helloworld.

` ` `sh
echo helloworld
` ` `

ルールがあるみたいで、最初に H2 で Tasks と書いて、各タスクは H3 で書いていくみたい。

中のスクリプトブロックを書いておくと実行してくれるという感じ。

実行すると以下のようになります。

$ xc helloworld
+ echo helloworld
helloworld

参考情報

xcfile.dev


過去の記事については、以下のページからご参照下さい。

サンプルコードは、以下の場所で公開しています。