menu/README
2025-09-11 21:27:18 -06:00

60 lines
1.7 KiB
Plaintext

```
[1]: . . .-- . . . .
[2]: |\ /| |-- |\| | |
[3]: ' ' ' '-- ' ' '-'
[0]: AGPLv3 2025
```
## Build
```sh
make
```
menu(1) is a single Rust source file with no dependencies, and can be compiled
on its own with rustc(1). It's recommended to run the test program:
```sh
make test
# or test using menu(1)'s shebang
./test
```
## Usage
```
menu [file]
```
If `file` is given, menu(1) reads its menu entries from `file` instead of
standard input.
## Menu format
Input is ignored until menu(1) reads two consecutive newlines (an empty line).
This is to provide room for commentary or a shebang (`#!/usr/bin/env menu` is
recommended). Following the two newlines, menu(1) will interpret input as a
stream of menu entries.
A menu entry begins with its text section, which is the section printed to
display the menu option.
Currently, the text section ends with a newline only, but in later versions the
text section will be able to be extended across multiple lines if they are
indented - so a newline followed by a character that isn't the horizontal tab.
The attributes section follows the text section. The attributes section ends
with a single newline. Text including and following a hash in the attributes
section will be ignoroed.
The command section follows the attributes section. The command section is
run as a single argument following the invocation `$ sh -c`, like the C
standard library's system(3). Each line in the command section is preceded by
a horizontal tab, which is removed from the argument; if a line in the command
section is not preceded by a tab, the omission is considered a syntax error (a
"naked line") and menu(1) exits unsuccessfully. The command section ends with
two consecutive newlines.