Skip to content

fix: ask for a new path each time a menu verb runs [patch] - #143

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/menu-path-reset-138
Sep 28, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/menu-path-reset-138

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #138

What changed

The interactive menu keeps one instance of each verb and runs that instance every time its item is chosen. A verb prompts for a path only when PathString is ".". Before this change, each verb reset PathString only on the last line of its Run. Any early return skipped the reset: no files found, no duplicates, or the user declining the confirmation. The next time that item was chosen, the verb skipped the prompt and ran against the old directory. The path the user typed was then read as the answer to the verb's next prompt; for Deduplicate that is "Proceed with deletion?", which by then targets a directory the user did not choose.

BaseVerb<T>.Run now restores isActive and resets PathString in a finally. That covers early returns and exceptions. I removed the four per-verb PathString = "." lines, since they are now redundant. On the command line each verb runs once, so behaviour there is unchanged.

Tests

New VerbReuseTests reuses one verb instance the way the menu does:

  • Deduplicate, DryRun and Scan ask for the path again after a run that found no duplicates.
  • Stats asks again after a run that found no files.
  • Deduplicate asks again after the user answers n at the confirmation, and the files in the first directory are still there.

With the FileDeduplicator/ changes reverted, all 5 tests fail. With the fix, the full suite has 51 passes and 0 failures. The other 2 tests are the existing permission-based ones, which report inconclusive when run as root.

This PR also touches Stats.cs, which #142 changes too. The two branches merge cleanly.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YLYtHwwqdY3Tk9vpkwT6Sw


Generated by Claude Code

The interactive menu runs one instance of each verb every time its item
is chosen, and each verb reset its path only on the last line of Run.
An early return (nothing found, no duplicates, a declined confirmation)
kept the old path, so the next run skipped the prompt and the path the
user typed was read as the answer to the next question instead.
BaseVerb<T>.Run now resets the path in a finally block, and the
per-verb resets are gone.

Fixes #138

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

Copy link
Copy Markdown

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.

In the interactive menu, a verb that exits early silently reuses the previous path instead of prompting again

2 participants