What's wrong
BaseVerb.PathString defaults to "." (Verbs/BaseVerb.cs:15). Each verb then checks if (PathString is "." or "") to decide whether to prompt for a path (Verbs/Deduplicate.cs:15, DryRun.cs:15, Scan.cs:15, Stats.cs:15). Because "." is both the default and the "not supplied" marker, an explicit -p . / --path . meaning "the current directory" can't be told apart from leaving the option out.
Failure scenario
These were run in a directory containing two identical files:
Scan -p . </dev/null prints Enter the path to scan: No path provided. Aborting. and does nothing. Scan -p ./ finds the duplicate group as expected.
echo y | Deduplicate -p . prints Enter the path to deduplicate: Deduplicating: <cwd>/y and then Directory not found: <cwd>/y. The y meant to confirm the deletion is read as the path. With different input piped in, the run could target a directory the user never meant.
Suggested fix
- Make
PathString a string? that defaults to null.
- Prompt only when
string.IsNullOrWhiteSpace(PathString).
- Reset it to
null rather than "." after a run.
Open PR #143 (for #138) moves the PathString = "." reset into a finally in BaseVerb<T>.Run. That PR is related but doesn't fix this, so the sentinel change should build on it.
Acceptance criteria
Scan -p . scans the current directory without prompting.
- Leaving out
-p still prompts.
What's wrong
BaseVerb.PathStringdefaults to"."(Verbs/BaseVerb.cs:15). Each verb then checksif (PathString is "." or "")to decide whether to prompt for a path (Verbs/Deduplicate.cs:15,DryRun.cs:15,Scan.cs:15,Stats.cs:15). Because"."is both the default and the "not supplied" marker, an explicit-p ./--path .meaning "the current directory" can't be told apart from leaving the option out.Failure scenario
These were run in a directory containing two identical files:
Scan -p . </dev/nullprintsEnter the path to scan: No path provided. Aborting.and does nothing.Scan -p ./finds the duplicate group as expected.echo y | Deduplicate -p .printsEnter the path to deduplicate: Deduplicating: <cwd>/yand thenDirectory not found: <cwd>/y. Theymeant to confirm the deletion is read as the path. With different input piped in, the run could target a directory the user never meant.Suggested fix
PathStringastring?that defaults tonull.string.IsNullOrWhiteSpace(PathString).nullrather than"."after a run.Open PR #143 (for #138) moves the
PathString = "."reset into afinallyinBaseVerb<T>.Run. That PR is related but doesn't fix this, so the sentinel change should build on it.Acceptance criteria
Scan -p .scans the current directory without prompting.-pstill prompts.