Skip to content

TODO follow-ups: corrupt-file backup, list JSON, reset confirmation, command-flow tests#2

Merged
StuartMeeks merged 5 commits into
mainfrom
feat/todo-improvements
May 27, 2026
Merged

TODO follow-ups: corrupt-file backup, list JSON, reset confirmation, command-flow tests#2
StuartMeeks merged 5 commits into
mainfrom
feat/todo-improvements

Conversation

@StuartMeeks
Copy link
Copy Markdown
Owner

Works through the post-0.1.0 TODO list. Each item is its own commit.

Changes

  • Backup corrupt settings file before falling back to defaults. A malformed file is copied to {file}.bak (best-effort) so the next write can't destroy recoverable content; startup still falls back to defaults instead of crashing.
  • settings list renders complex/collection values as compact JSON instead of bare type names (MyApp.Profile, List\1[...]`). Scalars unchanged.
  • settings reset confirms before overwriting (defaults to "no"), with -f/--force to skip — mirrors the Auth package's accounts delete.
  • Command-flow test harness — a Spectre.Console.Cli ITypeRegistrar→DI adapter + a TestConsole-backed runner driving the real CommandApp. New tests cover settings list and reset (declined / confirmed / --force / unknown-class), giving the confirmation prompt real coverage.
  • Docs: README gains a "Nested values & keeping it simple" section (in-place-mutation caveat + a prefer scalars recommendation); CHANGELOG updated under the still-Unreleased 0.1.0.
  • Removed TODO.md — every item is now resolved or dispositioned.

TODO dispositions

Item Outcome
Backup-on-corrupt-load ✅ done
settings list complex display ✅ done (JSON)
Confirmation prompt on reset ✅ done
settings get / set Decided against (favour flat scalar settings; documented)
INotifyPropertyChanged interop Deferred (YAGNI for a CLI lib)
Source generator Skip/much-later
External change detection Skip (fragile, low value for short-lived CLIs)
Hardened file permissions Deferred (secrets belong in the Auth package)

Quality

  • 32 xUnit tests, all green. Build clean (0 warnings).
  • No release tag; 0.1.0 stays Unreleased.

🤖 Generated with Claude Code

StuartMeeks and others added 5 commits May 27, 2026 04:16
When a settings file fails to parse, SettingsStore.Load() surfaced the
error and returned defaults — but the next write would then overwrite the
unreadable file, destroying any recoverable content. Copy it to a
"{file}.bak" sidecar (best-effort) before defaults take over. The
original is copied, not moved, so a backup failure loses nothing.

Adds a test: a malformed file falls back to defaults, surfaces the
JsonException, and leaves a .bak with the original content. Suite 22 -> 23.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`settings list` printed bare type names (e.g. "MyApp.Profile",
"System.Collections.Generic.List`1[...]") for any non-scalar property.
FormatValue now serialises complex/collection values as compact JSON so
the table stays informative; scalars are unchanged.

Also resolves the get/set TODO item: decided against it. The library
favours flat scalar settings, so a single-property CLI getter/setter
added conversion/complex-type surface without enough payoff. Documented
the nested-value caveats (in-place mutation isn't auto-saved) and a
"prefer scalars" recommendation in the README, and recorded the get/set
decision in TODO.

Adds 4 FormatValue tests (scalar string, bool, nested object -> JSON,
collection -> JSON). Suite 23 -> 27.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`settings reset` (and `reset --all`) overwrote saved files with no
confirmation. Both paths now prompt via AnsiConsole.ConfirmAsync,
defaulting to "no" since the operation is destructive and can't be
undone. A new -f/--force option skips the prompt for scripts/CI,
mirroring the Auth package's `accounts delete`.

README updated (prompt shown in the example + --force note); TODO item
cleared. The underlying ResetAsync/ResetAllAsync remain covered by the
store tests; the prompt itself is interactive glue (no command-flow
harness in the suite).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Introduce an end-to-end harness for the `settings` branch: a Spectre.Console.Cli
ITypeRegistrar adapter over Microsoft.Extensions.DependencyInjection (so
DI-constructed commands resolve as in a host app) plus a runner that
redirects the static AnsiConsole to a TestConsole for scripted prompt
input and output capture.

New CommandFlowTests cover: `settings list` rendering, and `settings
reset` declined / confirmed / --force / unknown-class — closing the gap
flagged when the reset confirmation prompt was added (the prompt now has
real coverage). Suite 27 -> 32.

Also remove TODO.md (all items resolved or dispositioned in commits/the
README) and drop its reference from the README Contributing section.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Record (under the still-Unreleased 0.1.0) the corrupt-file backup,
`settings list` JSON rendering of complex values, and the `settings
reset` confirmation prompt / --force. Bump the documented test count
22 -> 32 and note the new command-flow coverage.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@StuartMeeks StuartMeeks merged commit f0df176 into main May 27, 2026
2 checks passed
@StuartMeeks StuartMeeks deleted the feat/todo-improvements branch May 27, 2026 04:44
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