Advanced

Subcommands as a tree with one leaf

A tool with two jobs is a tool with a tree. The tree is why a job is chosen by a name, and one leaf is why a run has one shape.

What you will see

1. One leaf is one shape of answer.

About 1 min of reading

Try It

Print a tree on refusal

1

Write the tree

printf 'count\nwatch\nreport\n' > /tmp/t.txt; wc -l < /tmp/t.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
3. Three leaves is a tree a reader lists.
2

Attempt a wrong leaf

printf 'monitr\n' | grep -c -f -x /tmp/t.txt /dev/stdin | awk '{print ($1==0) ? "print tree" : "ok"}'

Before you run it, say out loud what it will print. Then open the answer.

What it prints
print tree. The tree is what makes the fix a name.
3

Prove one leaf per run

printf 'count\n' | wc -l

Before you run it, say out loud what it will print. Then open the answer.

What it prints
1. One leaf is one shape of answer.

Data Flow

A word to one leaf
1 The tree is written as names to names
↓
2 The first word chooses a branch
↓
3 The leaf is checked against the tree
↓
4 A leaf outside the tree prints the tree
Why this works
Why the tree is not a flag

A flag changes how a job runs. A leaf chooses the job, and choosing is a different decision.

The one depth that must not be passed

Three. A third depth is a name a person forgets, and a forgotten name is a tool that is not a tool.

Examples

The tree is written

Names to names. A written tree is a tree a reader lists, and a listed tree is a help that prints it.

One leaf per run

One leaf is one shape of answer. One shape is what makes a later command read either job the same way.

A leaf that is not in the tree refuses

The refusal prints the tree. The tree is what makes the fix a name rather than a guess.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

← Flags as a table with a short and a long name
Previous Lesson
Flags as a table with a short and a long name
Next Lesson
A config file as a layer under the words
A config file as a layer under the words →