Tasks
Module tasks
import tasks
| Module | tasks |
| Source | tasks/manifest.zirr, tasks/module-docs.zirr |
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 <name> runs one; a task whose name no built-in command claims also answers to zirric <name> directly.
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.
The dependency on future is for one declaration only: future.Proposal, the marker every attribute here carries to link itself back to ZE-002. Nothing unlanded is used, and none of it reaches a Cavefile.
Dependencies
Contents
Unions
Task
`tasks/manifest.zirr:14`
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:42`
attr Alias {
alias: Array
}
Provides alternative names for the task, flag or argument.
Fields
| Field | Description |
|---|---|
alias |
Alternative names. |
Arg
`tasks/manifest.zirr:68`
attr Arg
Marks this field as a positional commandline argument.
Call
`tasks/manifest.zirr:28`
attr Call {
function: Func
}
Indicates that this task is implemented by a function.
Fields
| Field | Description |
|---|---|
function |
The function to run for the task. It takes one argument: an instance of the declaration the attribute sits on. |
Exec
`tasks/manifest.zirr:21`
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:64`
attr Flag
Marks this field as a commandline flag.
Help
`tasks/manifest.zirr:57`
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:35`
attr Name {
name: String
}
Renames the task, flag or argument.
Fields
| Field | Description |
|---|---|
name |
The new name. |
Short
`tasks/manifest.zirr:50`
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:8`
const ZE_002
The proposal every declaration here links back to: ZE-002, The Cavefile.