5 releases (3 breaking)

0.6.0 Sep 26, 2021
0.5.1 Sep 26, 2021
0.5.0 Feb 21, 2020
0.4.0 May 6, 2019
0.1.0 Feb 13, 2019

#409 in Build Utils

AGPL-3.0-or-later

30KB
663 lines

Rhiz

A deliberately minimal task runner.

This is an in-progress-pre-alpha project.

Rhiz executes tasks defined in a "Rhizfile" which contains task descriptions with a Lisp-like syntax.

(task "hello"
  (log "Rhiz says hello"))

;; Comments start with a semicolon
(task "fizzbuzz"
  "Tasks can have an optional description"  ;; Strings with spaces are double-quoted.
  (exec fizzbuzz.exe)
  (log "The fizz was buzzed"))

(task "clean"
  (delete "./output"))

("task" echo
  ("echo" "Bare words and quoted strings are equivalent")))

Task execution

Tasks are executed relative to the directory containing the Rhizfile, not the directory where rhiz is invoked. When rhiz is invoked.

The commands in a task are executed one after the other, and if a command returns a non-zero exit code the the Rhiz immediately exits.

Commands

log

Prints a message to the standard output. Takes a single argument, which should be a string.

exec

Executes an external command (cargo, npm, etc.) in the Rhizfile's directory (usually the project root).

Takes one or more argument(s). The arguments are converted to strings; the first should be the name of an external program; the remainder should be it's arguments. They're executed using std::process:Command (effectively: Command::new(first_arg).args(rest_of_args))

.
empty-dir

Ensure a directory exists and is empty. Takes a single argument, which should be the path to a directory (relative to the Rhizfile).

If the directory exists, it's contents are deleted. Otherwise, it's created.

delete

Delete a file. It takes a single argument, which should be a file name or path (relative to the Rhizfile).

If the file indicated by the path exists it's delete with fs::remove_file If the file doesn't exist, this command is ignored.

copy

Copy a file. Takes two arguments: the source and destination paths for the copy.

The source should be the path to a file (relative to the Rhizfile). The destination can be a path to a directory (in which case the source file is copied there with the same name) or to a new file (in which case it's copied with the new name). If the destination file already exists, this command exits with an error.

The copy is performed using fs::copy

rec-copy

Recursively copies a directory. Takes to arguments: the source and destination paths for the copy.

Both the source and target directories should exist. The files and directories in the source are copied into the target.

par

Execute commands in parallel. Takes any number of tasks (written as s-expressions) as arguments.

Dependencies

~4MB
~83K SLoC