Prompt for Export's path and Search's query when run from the menu [patch] - #179
Merged
Merged
Conversation
…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
|
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.



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:Path.GetFullPath("")and crashed the app withArgumentExceptionwhenever the database was non-empty.Error: Search query cannot be empty.ScrollMenucreated 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 wayScanandImportalready do. An empty answer printsNo path provided. Aborting.orNo 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 theScrollMenunow wraps it in its existingActionCommand. 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.ExportRunWithAnEmptyAnswerAbortsCleanlySearchRunWithoutAQueryAsksForOneMenuItemsAskAgainOnEveryRun: the same menu action run twice asks for, and uses, two different queries.With the
Export.csandSearch.cschanges 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
ScrollMenupath on Linux, since it needs a real Windows console. Its change is the one-line switch toCreateVerbAction, whichMenuItemsAskAgainOnEveryRuncovers.🤖 Generated with Claude Code
https://claude.ai/code/session_01Kj95GdQsZpSCcND7LqacT1
Generated by Claude Code