Repository navigation
docs: give configuration its own page on the docs site - #178
Merged
Merged
Conversation
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.
This was referenced Sep 5, 2026
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Configuration gets its own page on the docs site:
docs/_tabs/configuration.md, atorder: 3. About moves toorder: 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
--config,$THINGS_CLI_CONFIG,$XDG_CONFIG_HOME,~/.config), and that a missing file is never an error, including a path you named yourself.--json=false).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_tagsexclusivity at load,dbexistence at resolve time) and the cross-flag override where--create-tagsbeatsstrict_tags = truefrom the command line.things config inittemplate verbatim.configcommands —path,show,init, each with real sample output in plain and--jsonform.db, with the actual error text and exit code.assume_yesand the skill commands — why the key is scoped tocomplete/canceland does not reachskill install/skill uninstall.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:tomlblock must matchTemplate()verbatim, so the example cannot drift from whatconfig initwrites;config.Keysentry, so a new key cannot land undocumented;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 testuntil both tables and, if the template changed, the example block are updated.Trimming the duplicates
docs/_tabs/commands.mdkeeps 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 --fixcaught seven problems in the first draft, all now fixed and each verified against the code:isInteractivereads stdin (cmd/things/main.go:1041), sothings complete "Roof" | tee logfrom a terminal still prompts. Rewritten, with an explicit sentence that piping output does not turn the prompt off.dbpath is caught when the CLI needs the database. The stat runs in the resolver, during flag resolution for every command, sothings config pathandthings config showfail on it too even though neither opens the database. Now stated accurately, withconfig pathin the sample so the blast radius is visible.no_verifyalso gates the tag-creation read-back (cmd/things/tags.go:269), sotag addand any--create-tagswrite are affected. The applies-to column said otherwise.assume_yes→--yes; carved out with a pointer to the section that explains why.--strict-tags/--create-tagscommand-line override was documented in the README but missing from the page.--json config showsample now says it is abridged.Build status
The page is unbuilt. There is no PR-time docs check —
pages.ymlruns only on push tomainunderdocs/**— and a localbundle exec jekyll buildis not possible here: system Ruby is 2.6.10 andjekyll-theme-chirpy ~> 7.2needs 3.1+, so building would mean installing a Ruby toolchain.Verified instead by inspection: front matter parses as YAML,
ordervalues 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/incommands.md, which resolves to/configuration/givenbaseurl: ""andpermalink: /:title/.Possible follow-up, not done here
A stale
dbentry makesthings config pathandthings config showfail — 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.