Skip to content

docs: give configuration its own page on the docs site - #178

Merged
ryanlewis merged 2 commits into
mainfrom
docs/configuration-page
Sep 5, 2026
Merged

ryanlewis merged 2 commits into
mainfrom
docs/configuration-page

Conversation

@ryanlewis

Copy link
Copy Markdown
Owner

What changed

Configuration gets its own page on the docs site: docs/_tabs/configuration.md, at order: 3. About moves to order: 4; Install (1) and Commands (2) are unchanged.

The config file previously had a section inside the Commands page and a longer one in the README, and neither had room for the annotated example, the subcommand output, or what the errors actually look like.

The page

  • Where the file lives — the four-step lookup (--config, $THINGS_CLI_CONFIG, $XDG_CONFIG_HOME, ~/.config), and that a missing file is never an error, including a path you named yourself.
  • Precedence — flag > file > built-in default, why it holds without exception (the file is a resolver the parser consults only for flags you did not pass), and how to spell a boolean override (--json=false).
  • Keys — a table generated from config.Keys: name, the spelling also accepted, type, default, which commands it applies to, and a one-line meaning. Plus the two constraints the CLI enforces (strict_tags/create_tags exclusivity at load, db existence at resolve time) and the cross-flag override where --create-tags beats strict_tags = true from the command line.
  • An example file — the things config init template verbatim.
  • The config commands — path, show, init, each with real sample output in plain and --json form.
  • When the file is wrong — unknown key, both spellings of one option, malformed TOML, bad enum value, and a stale db, with the actual error text and exit code.
  • assume_yes and the skill commands — why the key is scoped to complete/cancel and does not reach skill install / skill uninstall.
  • Notes for agents and scripts — that a config file can move defaults out from under you, and to pass the flags you depend on.

Every console sample is real output from a binary built at this commit, with the scratch paths rewritten to /Users/me/....

Keeping it in sync

Three tests in internal/config/docs_test.go:

  • the quoted toml block must match Template() verbatim, so the example cannot drift from what config init writes;
  • the key tables in both the page and the README must carry a row per config.Keys entry, so a new key cannot land undocumented;
  • the unknown-key error example must list the current key set.

They read the markdown from disk, which is the only way to check a docs file from Go. A key added to the registry now fails make test until both tables and, if the template changed, the example block are updated.

Trimming the duplicates

docs/_tabs/commands.md keeps a short Configuration section — what the file is, the three subcommands, the precedence line — and links to the new page. The README keeps its key table, since that is what people read on GitHub without the site, and gains a link to the page for the fuller treatment.

Corrections found while writing it

/code-review --fix caught seven problems in the first draft, all now fixed and each verified against the code:

  • The page said a run cannot prompt when output is piped. isInteractive reads stdin (cmd/things/main.go:1041), so things complete "Roof" | tee log from a terminal still prompts. Rewritten, with an explicit sentence that piping output does not turn the prompt off.
  • It said a stale db path is caught when the CLI needs the database. The stat runs in the resolver, during flag resolution for every command, so things config path and things config show fail on it too even though neither opens the database. Now stated accurately, with config path in the sample so the blast radius is visible.
  • no_verify also gates the tag-creation read-back (cmd/things/tags.go:269), so tag add and any --create-tags write are affected. The applies-to column said otherwise.
  • "Keys are named after the flag they set" is contradicted by assume_yes → --yes; carved out with a pointer to the section that explains why.
  • The --strict-tags / --create-tags command-line override was documented in the README but missing from the page.
  • The abridged --json config show sample now says it is abridged.

Build status

The page is unbuilt. There is no PR-time docs check — pages.yml runs only on push to main under docs/** — and a local bundle exec jekyll build is not possible here: system Ruby is 2.6.10 and jekyll-theme-chirpy ~> 7.2 needs 3.1+, so building would mean installing a Ruby toolchain.

Verified instead by inspection: front matter parses as YAML, order values are 1-4 with no clash, all 34 code fences balance, every markdown table has a consistent column count, the three {: .prompt-* } annotations sit directly under their blockquotes, and the page contains no Liquid of its own. The one Liquid expression added is {{ site.baseurl }}/configuration/ in commands.md, which resolves to /configuration/ given baseurl: "" and permalink: /:title/.

Possible follow-up, not done here

A stale db entry makes things config path and things config show fail — the two commands you would reach for to diagnose it. Same class as a malformed file stopping --help. Documented as-is rather than changed, since this task was the docs page; worth an issue if you want the diagnostic commands to survive a bad config.

The config file had a section inside the Commands page and a longer one
in the README, and neither had room for the annotated example, the
subcommand output, or what the errors look like.

Adds docs/_tabs/configuration.md at order 3 (About moves to 4) and trims
the Commands section to a pointer. The README keeps its key table, since
it is what people read on GitHub, and links to the page for the rest.

Three tests in internal/config guard the page against the registry: the
quoted template must match what config init writes, both key tables must
carry a row per key, and the unknown-key example must list the current
key set.
The page said a run cannot prompt when output is piped, but the check
reads stdin, so a piped-output run on a terminal still prompts. It said
a stale db path is caught when the CLI needs the database, but the stat
runs during flag resolution, so config path and config show fail too.
And no_verify also gates the tag-creation read-back, which the applies-to
column did not say.

Also documents that --strict-tags and --create-tags override each other
from the command line, and marks the abridged JSON sample as abridged.
@ryanlewis
ryanlewis merged commit cfa6373 into main Sep 5, 2026
7 checks passed
@ryanlewis
ryanlewis deleted the docs/configuration-page branch September 5, 2026 11:53
ryanlewis added a commit that referenced this pull request Sep 5, 2026
…sable (#180)

## What changed

A config file the CLI cannot use no longer disables the commands that
exist to tell you so. `things config path`, `things config show`,
`things config init` and `--help` all work against a file with a stale
`db` path, or one that will not parse at all.

## The stale `db` path

The `db` value was stat-checked in the config resolver, during flag
resolution, so a path that had moved broke every command — including the
two you would reach for to find the file.

The check moved to `(*Deps).Database`, at the point a command actually
opens the database. The error text and the attribution to the config
file are unchanged:

```
Error: config file ~/.config/things-cli/config.toml: db: stat /old/main.sqlite: no such file or directory
```

Getting there needed one more change than expected. Removing the check
from the resolver did not fix it, because `--db` carried
`type:"existingfile"` and kong's mapper stats resolver-supplied values
too — the failure just moved from my error to kong's, with a usage dump
and no mention of the config file. So `--db` is now `type:"path"` (still
expanding `~`), and this check covers both sources.

That means a nonexistent `--db` on the command line is reported when the
database is opened rather than at parse time, as `Error: cannot open the
Things database: …` instead of a usage block. `existingfile` also
rejected directories, so the replacement does that explicitly — sqlite
accepts a directory and fails much later with an opaque pragma error.

`config.File.SetsDB` is what lets the error name the file: it reports
whether the file is what put that path in play, so a path from `--db` or
from auto-detection is reported on its own terms.

## The unreadable file

Previously `loadConfig` failing meant `main` exited before the parser
existed, taking `--help` and the `config` commands with it.

Now a file that fails to load supplies no defaults but does not stop the
run. Parsing continues on built-in defaults, and the failure is reported
once the command is known — unless that command implements
`configDiagnostic`, a marker interface on `ConfigPathCmd`,
`ConfigShowCmd` and `ConfigInitCmd`. A marker rather than a name match,
so the exempt set cannot drift from the commands that implement it.
`--help` and `--version` never reach the gate; kong answers them during
`Parse`.

Behaviour against a broken file:

- `config path` prints the path and `(exists)`, warns on stderr that the
file cannot be used, and exits `0`. Which file is in use is a fact about
the path, not its contents. `--json` carries the problem in an `error`
field.
- `config show` prints `config: <path> (exists)` and then reports the
problem, exit `2`. Under `--json` the header is suppressed so it cannot
sit in front of the JSON object.
- `config init` refuses as usual but says why the file is unusable;
`--force` replaces it with a fresh template, so the file can be repaired
from the CLI.

## Two data-loss bugs found on the way

Both were mine, both are fixed and covered by tests.

`loadConfig` still returned `nil` alongside its error. The nil sent
`(*Deps).config()` to a fallback that resolved the **real** default
path, so `things --config <scratch> config init` ignored `--config` and
wrote to `~/.config/things-cli/config.toml`. `loadConfig` now always
returns the File it failed on, and the fallback no longer resolves a
real path — a `Deps` built without a config yields an empty File, and
`config init` refuses rather than inventing a destination.

`/code-review` then found that `Load` marked a file it could not
**read** (permission denied, or a directory at the path) as not
existing, so `config init` would silently overwrite it without `--force`
and exit `0`. `Exists` is now set whenever something is at the path.

## How tested

`make test` (`go test -race ./...`) and `make lint` clean.

`TestDiagnosticsSurviveABrokenConfig` runs `config path`, `config show`,
`config init` and `config init --force` against five kinds of broken
file — stale `db`, unknown key, malformed TOML, wrong value type, one
option under both spellings — asserting each command reports the file,
that `init` leaves it byte-for-byte unchanged, and that `--force`
produces a file that loads. Plus:

- `TestBrokenConfigStillParses` — parsing succeeds on a broken file and
seeds no defaults from it.
- `TestDiagnosesConfigMarksOnlyTheConfigCommands` — the marker covers
the three `config` commands and nothing else.
- `TestFlagBeatsStaleConfigDB` — parsing no longer fails on a stale
entry; `--db` opens fine; without it the error unwraps to
`*config.Error` naming the file.
- `TestMissingDBWithoutConfigAttribution` — a path no file supplied is
not blamed on one.
- `TestLoadMarksAnUnreadableFileAsExisting`, `TestSetsDB`,
`TestBrokenFileResolvesNothingButKeepsItsPath`,
`TestResolverPassesMissingDBThrough`.

The test harness in `run_test.go` now mirrors `main` — it keeps the File
on a load error and applies the same gate — so these paths are exercised
the way the binary runs them rather than through a shortcut.

Manually verified: `config init` refuses on a mode-0222 file and leaves
it untouched; `--db /tmp` reports a directory; `config path` with no
`$HOME` or `$XDG_CONFIG_HOME` reports that rather than printing an empty
path.

## Removed

The `*config.Error` branch in `main`'s parse-error handling. The
resolver no longer returns errors, so no parse failure can be a config
error, and the test covering that branch went with it. If a future key
can fail at parse time the branch should come back with a test.

## Docs

`docs/_tabs/configuration.md` had documented the old behaviour in #178 —
the "caught while the flags are resolved" paragraph and the warning that
a broken file stops `--help`. Both replaced, with a new "The diagnostic
commands always run" section showing the real output. README and
`commands.md` updated to match.

Closes #179
ryanlewis added a commit that referenced this pull request Sep 5, 2026
## What changed

Two commits, separable.

**`docs(site): add configuration tab to locale`** — the fix. Chirpy
takes a tab page's browser title from the `tabs:` map in
`docs/_data/locales/en.yml`, keyed by the lowercased page title. The map
listed `install` and `commands` but not `configuration`, so the tab
added in #178 rendered with an empty `<title>`. One line:
`configuration: Configuration`.

**`docs(site): fall back to the page title when a tab has no locale
entry`** — optional, drop it if you would rather not touch the override.
`docs/_includes/head.html:63` reads the locale map with no `default:`
filter, which is why a missing key produced an empty title rather than
an imperfect one. The theme's own equivalents both carry the fallback,
so the override looks like it diverged by accident:

| Where | Code | Fallback |
| --- | --- | --- |
| `docs/_includes/head.html` (this repo) |
`site.data.locales[include.lang].tabs[tab_key]` | none — **the bug** |
| theme `_includes/sidebar.html` | `... tabs.[tab_name] \| default:
tab.title \| upcase` | yes |
| theme `_layouts/page.html` | `... tabs[tab_key] \| default:
page.title` | yes |

Adding `| default: page.title` matches upstream and makes the next tab
self-healing.

## What else depends on the locale

Nothing else on the page was broken. The sidebar label and the `<h1>`
both go through the theme, and both already fall back to the
front-matter title, so they rendered "CONFIGURATION" and "Configuration"
correctly all along — the empty `<title>` was the only symptom.
`jekyll-seo-tag` uses `page.title` directly and is unaffected.

Checked every tab against the map: `about`, `commands`, `configuration`
and `install` all now have a key matching their lowercased title.

## How verified

Not by building the site — there is no PR-time docs check (`pages.yml`
runs only on push to `main`), and a local `bundle exec jekyll build` is
not possible here: system Ruby is 2.6.10 and `jekyll-theme-chirpy ~>
7.2` needs 3.1+.

Instead: `en.yml` parses as YAML with the expected `tabs` map, every
`docs/_tabs/*.md` front-matter title lowercases to a key present in it,
and the two theme templates were read at the `v7.2.4` tag to confirm
where the fallbacks are and that `head.html` is the only place without
one.

`make test` and `make lint` are clean, though neither touches the site.

## Possible follow-up

A tab whose locale key is missing is now cosmetic rather than broken, so
nothing further is needed. If you would rather it were caught outright,
a check that every `docs/_tabs/*.md` title has a key in `en.yml` would
do it — it is the same shape as the docs-sync tests from #178, though it
would need a home, since nothing under `docs/` is Go.
ryanlewis added a commit that referenced this pull request Sep 5, 2026
## What changed

"A missing file is not an error" describes the config file by what does
not go wrong. "The file is optional" says what it is. Replaced
everywhere it appeared.

**User-facing text:**

- `docs/_tabs/configuration.md` — the callout under the lookup table:

> **The config file is optional.** Without one, `things` runs on its
built-in defaults. The same applies to a path you name yourself; run
`things config path` to see which file is in use and whether it exists.

- `README.md` — "The file is optional — without one, `things` runs on
its built-in defaults."

- `internal/config/config.go`, the `config init` template header:

  ```
  # Read from $XDG_CONFIG_HOME/things-cli/config.toml, or
  # ~/.config/things-cli/config.toml. Override with --config PATH or
  # $THINGS_CLI_CONFIG. The file is optional; without it, things runs on
  # its built-in defaults.
  ```

Wrapped over two lines to stay inside the 72 columns the rest of the
header uses; the suggested single line was 73.

**Doc comments**, so the code reads the same way as the docs: the
comments on `config.File` and `config.Load` now say the file is optional
rather than that its absence is not an error.

## The template and the page

The `toml` block on the configuration page has to stay byte-identical to
`Template()` — `TestDocsPageQuotesTheTemplate` enforces it — so both
changed together. The page block was regenerated by running `things
config init` and pasting the result, not hand-edited, so the two cannot
have drifted in the edit.

## Also checked

`docs/_tabs/commands.md` and `internal/skill/SKILL.md` do not carry the
phrase. Neither describes the missing-file case at all: `commands.md`
links to the configuration page for it, and SKILL.md says "the user
**may** have a TOML file", which already reads as optional. Left both
alone.

`grep -rn "not an error"` across `README.md`, `docs/`, `internal/` and
`cmd/` now returns nothing.

## How tested

`make test` (`go test -race ./...`) and `make lint` clean, including the
three docs-sync tests from #178 — the template check is what proves the
page and the binary still agree.

Not verified by building the site, for the reasons in #178 and #181: no
PR-time docs check, and no local Ruby new enough for
`jekyll-theme-chirpy ~> 7.2`. The page edits are prose inside an
existing callout and an existing fenced block, with no structural
change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant