Command line

Every option, the formats, the keys used most, the limits, and the exit statuses, as aless --help prints them in full.

This page is the reference that aless --help prints for aless 0.8.0. aless -h prints a summary of the options. man aless prints this reference as a man page. The same text is also in the plain-text file command-line.txt, as the terminal shows it.

Usage #

aless [OPTIONS] [FILE]...
each FILE in a tab of its own
aless [OPTIONS] DIRECTORY
the directory, in the explorer
COMMAND | aless [OPTIONS]
standard input, read as JSON unless -k says otherwise

-h prints a summary of the options. --help prints this whole reference.

The viewer #

aless is a viewer for the terminal. Each FILE opens in a tab of its own, as a tree: you can fold the tree, search it, and copy from it. A directory opens in the explorer. With no FILE, aless reads standard input when standard input is not a terminal. Otherwise aless explores the current directory. aless watches every file: when a file changes on disk, aless reads it again and keeps your place. A file that does not parse opens as the parser's report. The report gives the line and column where the parse stopped.

aless refuses to start without a terminal to draw on and read keys from. It refuses when standard output is a pipe or a file, when there is no terminal to open, or when TERM is dumb. It refuses before reading any input. It writes one line on standard error and exits with the status 2. Only -h, --help, -V, --generate, and --print-json write to standard output. --print-json is the one option that reads an input without a terminal: it prints the input's tree as JSON, and exits.

Input options #

What is read, and how

-k, --kind, --format <FORMAT> #

Read every input as FORMAT, whatever its extension says. FORMAT is a format's name (json, jsonl, jsonic, jsonc, json5, yaml, toml, ini, csv, tsv, xml, zon, markdown, feed, css, proto, pgn, c, abnf, ebnf, gbnf, expr, semver, or text), one of its extensions (yml, md, ndjson), or a --grammar NAME. Standard input is read as JSON unless this option says otherwise. --format is another name for this option.

--grammar <NAME=FILE> #

Read every file whose extension or whole name is NAME (x.hosts, /etc/hosts) with the ABNF grammar in FILE. The match ignores case. NAME is then a format: -k and :format take it, and the status bar shows it. NAME,NAME2=FILE gives the format two names. You can give the option more than once. aless reads and compiles FILE before it reads any input, so a FILE that does not compile is a usage error. The read is held to --max-size, and the compile to --timeout. For more information, see Custom grammars.

--grammar-expr <NAME=ABNF> #

Do what --grammar does, with the grammar's text on the command line in place of FILE. The text is everything after the first =.

--max-size <SIZE> #

Refuse an input larger than SIZE, a --grammar file included. The default is 64M, and 0 is no limit. SIZE is bytes, or a whole number with K, M, or G, counted in 1024s. A file over the limit opens in a tab that says so and names the size that would read it. A grammar file over the limit is a usage error. A parse needs about 40 bytes of memory for each byte of input.

--timeout <SECONDS> #

Stop a parse, or a --grammar compile, that runs longer than SECONDS. SECONDS is a number of seconds (2.5, 90s) or of minutes (2m). The default is none, and 0 is no limit. An input whose parse is stopped opens in a tab that says how far the parse got. A compile that is stopped is a usage error. A parse runs at about 1 MB a second. For more information, see Large inputs and limits.

Viewer options #

How the input is shown

--no-watch #

Do not reload a file when it changes on disk. Inside aless, W or :watch on starts watching a tab.

--watch #

Reload a file when it changes, and keep your place in it. Reloading is the default.

--no-changes #

Do not mark what each reload changed. aless keeps the versions all the same, and [ and ] show them. Inside aless, :set changes turns the marks on.

-m, --mode <MODE> #

Start in data mode or in line mode. The default is data mode. Data mode shows the tree without its punctuation. Line mode shows the tree as JSON prints it, with the punctuation that data mode leaves out. Inside aless, m switches between them.

--depth <N> #

Open only the first N levels when a file opens. A container N levels below the root starts folded, and so does everything in it. So --depth 0 folds the root. By default, every container is open. Inside aless, :depth N opens the first N levels in the same way.

--indent <N> #

Indent the tree N spaces a level. The default is 2, and the limit is 16. Inside aless, < and > change the indent.

-n, --line-numbers #

Number the rows on screen. Each number is the count g or G needs to reach the row.

-N, --no-line-numbers #

Do not number the rows. This option undoes an -n before it.

-r, --relative-line-numbers #

Number each row by its distance from the focused row. That distance is the count j or k needs to reach the row. With -n as well, the focused row shows its own number.

-R, --no-relative-line-numbers #

Do not number the rows by distance. This option undoes an -r before it.

--scrolloff <N> #

Keep N rows between the focused row and the top or the bottom of the screen. The default is 3.

--ascii #

Draw the fold markers as v and >, for a font without triangles. By default, aless draws the markers as triangles.

--no-color, --no-colour #

Draw without colour, as when NO_COLOR is set.

--no-mouse #

Leave the mouse to the terminal, for its own selection. By default, aless takes the wheel and the clicks of the mouse.

Other options #

-h, --help #

Print a summary of the options (-h), or this whole reference (--help).

-V, --version #

Print the version: aless 0.8.0.

--generate <WHAT> #

Print a file written from this reference. WHAT is man for the man page. The man page is aless.1. WHAT is complete-bash, complete-zsh, complete-fish, or complete-powershell for that shell's completions. For more information, see Files.

--print-json <FILE> #

Print the tree of FILE as JSON on standard output, and exit. The viewer does not start, so no terminal is needed. FILE is read as the viewer reads it: -k, --grammar, --grammar-expr, --max-size, and --timeout apply, and the viewer's options make no difference. FILE - is standard input, read as JSON unless -k says otherwise. The JSON is what :w writes: two spaces a level, the keys in their order in the source. When FILE cannot be read or does not parse, the report goes to standard error and the exit status is 1.

Input and formats #

FILE is a path, or - for standard input. Options end at --, so every argument after -- is a FILE, even one that starts with -. A long option's value follows it, or is attached with = (--kind=yaml).

A file's format comes from its extension, or from its whole name when that name is a --grammar NAME (/etc/hosts). -k FORMAT overrides the format for every input. Inside aless, :format FORMAT reads a tab again as FORMAT, and :open PATH FORMAT opens a file as FORMAT. A file whose extension no format claims is read as plain text: an array of its lines.

Keys keep their order in the source. A number keeps its spelling where JSON spells it the same way. So 1.0, 1e21, and an integer beyond 2^53 are shown, searched, copied, and written by :w as the source writes them. Where JSON has no syntax for a spelling, such as 0x1F, 1_000, or +1, aless reads the number as the 64-bit float that the spelling stands for. The source view (s) shows the spelling.

These are the formats, each with the extensions that imply it:

FormatExtensions
jsonjson geojson har jsonld webmanifest
jsonljsonl ndjson
jsonicjsonic
jsoncjsonc (trailing commas accepted)
json5json5
yamlyaml yml
tomltoml
iniini cfg conf cnf
csvcsv (records keyed by the header row)
tsvtsv tab (as csv)
xmlxml svg xhtml xsd xsl xslt plist
zonzon
markdownmd markdown (its syntax tree)
feedrss atom (normalised to an Atom shape)
csscss (its syntax tree)
protoproto (its FileDescriptorProto, as protoc writes one in JSON)
pgnpgn (chess games, each its tags and moves)
cc h (its concrete syntax tree, every token with its place)
abnfabnf (the grammar spec its compiler writes, the three notations' one schema)
ebnfebnf (the grammar spec its compiler writes, the three notations' one schema)
gbnfgbnf (the grammar spec its compiler writes, the three notations' one schema)
exprnone, -k expr (jsonic with arithmetic, where each operation is the list of its operator and terms)
semvernone, -k semver (a version: its major, minor, patch, prerelease, and build)
texttxt text log (and any file no format claims)

Keys #

The keys are those of jless. Inside aless, F1 or :help lists every key and command. These are the keys used most:

j k
Move down and up a row. A count before a key repeats it (3j).
h l
Fold and unfold, or go to the parent and the first child.
J K
Go to the next and the previous sibling.
g G
Go to the first and the last row. Ng goes to row N.
Ctrl+D Ctrl+U
Move half a page down and up.
Space
Fold or unfold the focused container.
c e
Fold and unfold the focused node and its siblings.
/ ?
Search forward and backward. The keys n and N go to the next and the previous match.
yy yp yq
Copy the value, its path, or its path as jq writes it.
m
Switch between data mode and line mode.
s
Show the source view, at the focused node's line.
!
Show the parse error report full size.
Tab Shift+Tab
Go to the next and the previous tab.
:
Start a command, such as :open PATH, :format FORMAT, :w FILE, or :help.
q
Close the tab. Closing the last tab quits. Ctrl+C quits.

Custom grammars #

--grammar NAME=FILE uses the ABNF grammar in FILE to read every file whose extension or whole name is NAME. The match ignores case. The grammar is ABNF as RFC 5234 defines it, and tabnas/abnf compiles it. -k NAME reads any input with the grammar, standard input included. Comments on a rule say what it builds: ; @object a b makes an object of its parts a and b, and ; @array makes an array. Without them, the value is the compiler's parse tree: a {"rule", "src", "kids"} node for each rule.

A grammar reads its input as plain text. In the input, the characters { } [ ] : and , are ordinary, # starts a comment that runs to the end of the line, and a word is the token TX. NR brings back numbers, ST brings back quoted strings, and VL brings back true, false, and null.

A grammar that does not compile is refused as a usage error, before any input is read. So is a repetition count over 1,024, or repetitions that would have the compiler write more than 1,024 rules. An input the grammar does not accept opens as a parse error. The input's format is the grammar's name.

The source of aless holds grammars for /etc/hosts, crontabs, /etc/passwd, /etc/group, /etc/fstab, /etc/resolv.conf, and KEY=value files. Each grammar comes with a sample. The grammars, their samples, and a guide to writing a grammar are in this directory:

https://github.com/rjrodger/aless/tree/main/tests/fixtures/grammars

Large inputs and limits #

aless reads an input whole, and parses it whole, before it shows anything. A parse runs at about 1 MB a second. It needs about 40 bytes of memory for each byte of input. The viewer waits for the parse, so aless says when it starts to read a large file. A reload of a large watched file pauses the viewer until the parse ends.

--max-size refuses an input larger than its limit before reading it. The default limit is 64M. An input over the limit opens in a tab that says so and names the size that would read it. --timeout stops a parse that runs too long. An input whose parse is stopped opens in a tab that says how far the parse got.

A document nested too deep for aless opens as a parse error with the code too_deep. Every parse stops at 3,000 open rules, about 1,000 levels. Most grammars stop sooner. JSON, JSONL, jsonic, JSON5, YAML, TOML, INI, ZON, and expressions stop at 127 levels. XML stops at 256, JSONC at 512, and CSS at 768 open rules. The braces of a .proto file can nest 100 deep. aless counts the braces before it parses the file. The Markdown tree stops at 205 levels, without an error.

C stops at an expression of about 127 operations, at 1,024 open rules, or at a syntax tree 256 levels deep. Its tree repeats subtrees, so C also stops at a tree with more than 256 values for each byte of the file, or with more than 2,048 bytes of names and strings for each byte of the file. Those limits are between 1,048,576 and 33,554,432 values, and between 8 MB and 256 MB. A grammar in ABNF, EBNF, or GBNF can nest its groups and elements 127 deep.

Exit status #

0
You quit the viewer, or --print-json printed its file's tree.
1
The viewer failed while it ran: aless could not draw on the terminal or read from it. Or --print-json could not read its file, or the file did not parse, and the report is on standard error.
2
The viewer could not start, or --print-json could not. Either there was a usage error, or there was no terminal to draw on and read keys from. A usage error is an unknown option, a bad value, or a --grammar that does not compile or cannot be read.

Environment #

NO_COLOR
set and not empty: draw without colour, as --no-color does
TERM
dumb: a terminal that cannot draw the viewer, so aless refuses to start, as it does without a terminal

Files #

A release archive carries the man page and the completions. --generate prints them as well:

man/aless.1
the man page (--generate man)
completions/aless.bash
the completions for bash (--generate complete-bash)
completions/_aless
the completions for zsh (--generate complete-zsh)
completions/aless.fish
the completions for fish (--generate complete-fish)
completions/_aless.ps1
the completions for PowerShell (--generate complete-powershell)

A shell reads its completions from where it looks for them. A package puts them there. A shell can read them from its startup file instead, each time it starts:

eval "$(aless --generate complete-bash)"     # ~/.bashrc
eval "$(aless --generate complete-zsh)"      # ~/.zshrc, after compinit
aless --generate complete-fish | source      # config.fish

Examples #

CommandDoes
aless config.yamlone file, in a tab
aless deploy.yaml values.toml a.csvseveral files, a tab each
curl -s https://api.example/x | alessstandard input, read as JSON
aless -k yaml settings.confa file whose extension misleads
aless --grammar hosts=hosts.abnf /etc/hostsa format of your own
aless --no-watch big.jsonno reload when the file changes
aless -m line -n x.jsonline mode, the rows numbered
alessexplore the current directory

See also #

jless(1)
the viewer whose keys and design aless follows
jq(1)
the tool whose path syntax the key yq copies
the documentation
a tutorial, how-to guides, this reference with every key, and why aless works as it does: https://aless.tabnas.dev
the source
the code and the releases: https://github.com/rjrodger/aless
tabnas/abnf
the ABNF compiler --grammar uses, and its annotations: https://github.com/tabnas/abnf

This page describes aless 0.8.0. Written from src/cli.rs · This page as Markdown