Skip to content

zakuro9715/z

Repository files navigation

Z

Go codecov Go Report Card License: GPL v3

Simple task runner

Installation

Via gobinaries

curl -sSL gobinaries.com/zakuro9715/z | sh

By go install

go install github.com/zakuro9715/z

Usage

z tasks... args...

Config

Run

Run with specified shell (default: sh)

tasks:
    hello:
        run:
            - echo hello1
            - echo hello2
$ z hello

# It runs
sh -c "echo hello1"
sh -c "echo hello2"

run can be omitted

tasks:
  hello: echo hello

Shorthand

tasks:
    hello.world: echo hello world
$ z hello world
hello world
$ z hello.world
hello world

Args or flags

You can specify args and flags. They are passed to each commands

$ z hello world

# It runs
sh -c "echo hello1 world"
sh -c "echo hello2 world"

You can pass flags and args. They will be passed to each commands

Default task

You can use default task

default: hello.world
tasks:
    hello:
        tasks:
            world: echo hello world
$ z
hello world

Examples

See also Examples Test

tasks:
  compile:
    run:
      - clang $@
    desc: Compile
    hooks:
      pre: echo Compiling
      post: echo Compiled
    tasks:
      main:
        run:
          - z -c examples/cc.yaml compile main.c
shell: bash                        # Shell to run commands
default: hello.world               # Default task. hello.world -> z hello world
env:
  MESSAGE: message                 # It used if environment variable does not exist.
tasks:                             # Task list
  hello:                           # Task name
    desc: Say hello                # Task description
    run:                           # Commands to run
      - echo hello                 # `bash -c "echo hello {args}`
      - echo bye                   # `bash -c "echo bye {args}"`
    args:
      required: true               # Required one more arguments
      default: you                 # Default argument
    hooks:                         # hooks
      pre: echo saying hello       # pre hook
      post: echo said hello        # post hook
    tasks:                         # Sub task list
      script:
        run: examples/hello.sh     # Run script

      python:
        shell: python
        run: print('hello python')

  hello.world:                     # Sub task shorthand (Task will be 'z hello world')
    run:
      - z hello -- world           # Args are passed all commands
                                   # so it runs 'bash -c "echo hello world"' and 'bash -c "echo bye world"
                                   # after -- is args (not subtask name)
  echo: echo                       # Shorthand command ('run' can be omitted').
  echo.twice:                      # Multi commands can be used
    - echo
    - echo
  echo.env.message: echo $MESSAGE  # use env
  echo.env.message2:
    env:                           # task local default env
      MESSAGE: message2
    run: echo $MESSAGE