Tasks

Module tasks

import tasks

Declaring a subcommand, with typed flags and arguments.

A task is a data declaration in the Cavefile carrying either Exec or Call. zirric task lists them and zirric task run — or zirric x — runs them.

The difference between the two is what happens when it runs. Exec runs a script as its own program, which reads its own arguments through os.args(). Call invokes a function directly with an instance of the declaration, built from the parsed flag and argument values — so the fields are typed and the CLI does the parsing.

The remaining attributes describe the command line: Name and Alias name it, Short and Help document it, and Flag and Arg mark which fields are flags and which are positional.

Dependencies


Contents


Unions

Task

`tasks/manifest.zirr:15`
union Task {
	Exec
	Call
}

Marks a data declaration as a task.
The task can be executed from the command line.
Exactly one of @Exec or @Call is required.

Cases

Case Interpretation
Exec Indicates that this task is implemented in an external file.
Call Indicates that this task is implemented by a function.

Attributes

Alias

`tasks/manifest.zirr:43`
attr Alias {
	alias: Array
}

Provides alternative names for the task, flag or argument.

Fields

Field Description
alias Alternative names.

Arg

`tasks/manifest.zirr:69`
attr Arg

Marks this field as a positional commandline argument.


Call

`tasks/manifest.zirr:29`
attr Call {
	function: Function
}

Indicates that this task is implemented by a function.

Fields

Field Description
function The function to run for the task.

Exec

`tasks/manifest.zirr:22`
attr Exec {
	file: String
}

Indicates that this task is implemented in an external file.

Fields

Field Description
file The file that contains the implementation of the task.

Flag

`tasks/manifest.zirr:65`
attr Flag

Marks this field as a commandline flag.


Help

`tasks/manifest.zirr:58`
attr Help {
	help: String
}

A short help text for the task, flag or argument.

Fields

Field Description
help A short help text.

Name

`tasks/manifest.zirr:36`
attr Name {
	name: String
}

Renames the task, flag or argument.

Fields

Field Description
name The new name.

Short

`tasks/manifest.zirr:51`
attr Short {
	short: Char
}

Provides a short name for the flag.
Not applicable to arguments.

Fields

Field Description
short The short name of the flag.

Constants

ZE_002

`tasks/manifest.zirr:9`
const ZE_002

ZE-002: Error Handling
https://zirric.knabel.dev/proposals/ze-002-the-cavefile/