Skip to content

Prompt for Export's path and Search's query when run from the menu [patch] - #179

Merged
matt-edmondson merged 2 commits into
mainfrom
fix/156-menu-prompts
Sep 29, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
fix/156-menu-prompts

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #156

What was wrong

The menu runs verbs directly, without CommandLineParser. CommandLineParser is the only thing that enforces Required = true, so from the menu:

  • Export reached Path.GetFullPath("") and crashed the app with ArgumentException whenever the database was non-empty.
  • Search always printed Error: Search query cannot be empty.
  • The Windows ScrollMenu created each verb once and reused it for the whole session. After one Import, every later Import skipped its prompt and imported the same file again. Scan did the same after an early return.

Change

  • Export.ValidateArgs / Search.ValidateArgs: prompt for the output path or query when it is empty, the way Scan and Import already do. An empty answer prints No path provided. Aborting. or No query provided. Aborting. and returns cleanly.
  • Menu.CreateVerbAction(Type): returns an action that creates a fresh verb instance on every run. Both menus now use it: the prompt menu used an inline equivalent before, and the ScrollMenu now wraps it in its existing ActionCommand. Nothing typed for one run carries into the next.

Tests

New tests in MenuTests, run against a one-entry database with the console redirected:

  • ExportRunWithoutAnOutputPathAsksForOne: prompts, then writes the JSON file.
  • ExportRunWithAnEmptyAnswerAbortsCleanly
  • SearchRunWithoutAQueryAsksForOne
  • MenuItemsAskAgainOnEveryRun: the same menu action run twice asks for, and uses, two different queries.

With the Export.cs and Search.cs changes reverted, all four fail. With the change, the full suite passes: 62 tests, 1 skipped as before because the root user can read every folder.

I could not exercise the ScrollMenu path on Linux, since it needs a real Windows console. Its change is the one-line switch to CreateVerbAction, which MenuItemsAskAgainOnEveryRun covers.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Kj95GdQsZpSCcND7LqacT1


Generated by Claude Code

…atch]

The menu runs verbs without CommandLineParser, so Export's required -o
and Search's required -q were never asked for: Export crashed on
Path.GetFullPath("") and Search always reported an empty query. Both now
prompt in ValidateArgs, as Scan and Import already do, and abort cleanly
on an empty answer.

The Windows scroll menu also built each verb once and reused it for the
whole session, so a second Import re-imported the first file without
asking. Both menus now run a fresh verb instance per selection.

Fixes #156

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kj95GdQsZpSCcND7LqacT1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kj95GdQsZpSCcND7LqacT1
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit fce3207 into main Sep 29, 2026
12 checks passed
@matt-edmondson
matt-edmondson deleted the fix/156-menu-prompts branch September 29, 2026 07:10
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.

From the interactive menu, Export crashes the app and Search always fails: neither prompts for its required -o / -q argument

2 participants