6.14. Directive reference
Every docstring directive that affects the generated interface, grouped by where it may be written. A directive written in the wrong place is not an error; it is kept as prose and the build warns, so check this table when one appears to do nothing.
| Directive | Effect |
|---|---|
|
Open a block. Every following docstring line, until the docstring ends,
is printed verbatim below the options from |
| Directive | Effect |
|---|---|
|
Name the subcommand something other than the Morloc term. |
|
Attach an output action whose result stays typed. See Output actions. |
|
Attach an output action whose result is written as final bytes. |
|
Describe the return value. The same as a docstring on the signature’s last type. |
|
Open a block printed verbatim at the foot of this subcommand’s help, after its argument and return blocks. Use it for the command’s own "Examples:" section. The top-level help shows only the module’s block. |
| Directive | Effect |
|---|---|
|
Make this argument an option rather than a positional. Requires |
|
The value used when an option is omitted, written as JSON. |
|
On a |
|
On a |
|
Name the argument. Becomes the placeholder in help for an option, and the property name in the machine-readable views. |
|
Accept several argv tokens and assemble them into a list. The argument type must be a list; as a positional it must be the last one. |
|
Make a |
|
Where the bytes come from. See Input shape. |
|
How the bytes are read. |
|
Require the argument to be a path satisfying the mode. |
|
The same three, applied to each element of a |
|
On a record argument: split it into one flag per field. |
| Directive | Effect |
|---|---|
|
On a |
|
Attach a media type to a type. See Output actions. |
|
On a record field: the same meaning as on an argument, applied when the record is unrolled. |
|
On a |
| Token | Meaning |
|---|---|
|
On a |
|
On a |
|
As a handler argument under |
|
As a handler argument: the value being formatted. Appended last if not written explicitly. |
|
As a handler argument: the command’s own Nth argument. |
One more directive is a deprecated spelling rather than a feature:
literal: true means @source inline. It still works, and the build warns
when you use it.