Export command (CSV + ODS), file dialog, error modal, path persistence.

New user-facing features:
- `export connections <file>` writes a tabular dump of every wire pair:
  connection, transform, left/right module/part/pin/signal/type/suspect,
  mixed-types flag. Dispatch on extension: `.csv` (flat file) or `.ods`
  (one sheet per connection). Any other extension shows an error and
  writes nothing.
- Bare `export` (or dashboard `[x]`, or palette `export`) opens an
  interactive file-picker dialog with a CSV/ODS toggle at the top.
  Picking a filter rewrites the filename's extension. Last-used
  directory and filename are remembered per-call-site.
- Two new CLI flags on the binary: `--source FILE` to run a script at
  boot, `--restore FILE` to restore a snapshot at boot. Combinable.

Reusable infrastructure:
- `OdsWriter` (`src/imports/ods_writer.{hpp,cpp}`): minimal .ods writer
  using libzip + pugixml (already in the build for the importer).
  Multi-sheet workbook of string cells. ~180 lines, no new dep.
- Generic file-picker dialog (`screen_filedialog.cpp`): one Modal
  reused for any "pick a path" interaction via
  `OpenFileDialog(title, persist_key, default_filename, filters, cb)`.
  Validates the picked extension against the filter whitelist;
  unknown ones stay in the dialog with a status message. Persists
  (dir, filename) per `persist_key`.
- Generic error modal (`screen_error.cpp`, `ShowError(msg)`): centred
  red-titled popup, dismissable with Esc/Enter. Used by the export
  failures (open-for-write, ODS save, unknown extension/kind);
  ready for adoption elsewhere.
- Per-key path persistence (`SaveLastUsed`/`LoadLastUsed` in
  `shell.cpp`): two-line file per key under the user-data dir.
- `UserDataDir()` extracted from the history path helper so the new
  per-key persistence shares the same XDG/AppData logic.
- New help-screen topic "Export"; user-facing `doc/user/analysis.md`
  gains an "Exporting" section; `DESIGN.md` gains a generics
  section covering the dialog / error modal / persistence / ODS
  writer; `DumpCommandsMd` now respects the `hidden` flag (the
  `connect` alias no longer appears in the auto-gen reference).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-16 12:03:39 +02:00
parent f62f4a0c9b
commit 7d307dad57
18 changed files with 1085 additions and 103 deletions

View File

@@ -142,3 +142,21 @@ Every classification is advisory. To force a different type:
Overrides survive `save`/`restore` but are recomputed at every
`load` (i.e. the inference re-runs).
## Exporting
Dump structured data to an external file:
- `export connections <file>` — every wire pair, one row, with the
signals and types on both sides plus a `suspect` flag (name says
Power but the structural check disagreed) and a `mixed` flag
(both sides typed but disagreeing).
- The dashboard's `[x]` shortcut, the `export` command without
arguments, or the palette entry `export`: opens an interactive
file-picker dialog. A small toggle at the top of the dialog lets
you pick the format — **CSV** (flat, one row per wire) or
**ODS** (one sheet per connection, opens directly in
LibreOffice / Excel). The dialog remembers the directory and
filename you used last so the next export resumes from there.
- Inline scriptable form: `export connections /path/foo.csv` (or
`.ods`). Unknown extensions raise an error popup.