A root that does not exist produces the same output as a disk with
nothing on it:
$ diskern scan /nonexistnt-path
Scanned 0 files.
Reclaimable: 0 B across 0 findings and 0 duplicate sets.
$ echo $?
0
So does no path at all — roots is a plain Vec<PathBuf> with no
required, and diskern scan on its own is accepted, scans nothing and
exits 0:
$ diskern scan --json
{
"findings": [],
"duplicate_sets": [],
"total_reclaimable": 0,
"files_scanned": 0
}
Both are the worst answer a disk tool can give a typo: "there is nothing
here" is a plausible result, so nothing tells the user to look again. The
--json case is the one that hurts downstream — a script cannot tell an
empty report from a mistyped path.
The walk swallows it on purpose one layer down: walk_root skips entries
jwalk returns an error for, which is right for the permission errors it
was written for and wrong for a root that was never there.
Two small changes in the CLI, and they can be one PR:
- make the argument required (
#[arg(required = true)], or num_args = 1..)
so clap prints the usage error itself;
- check each root exists before scanning and fail with the path that was
wrong, rather than reporting an empty scan.
A non-zero exit code for the second case matters as much as the message.
crates/diskern-cli/src/main.rs:22 · crates/diskern-cli/src/main.rs:200
A root that does not exist produces the same output as a disk with
nothing on it:
So does no path at all —
rootsis a plainVec<PathBuf>with norequired, anddiskern scanon its own is accepted, scans nothing andexits 0:
Both are the worst answer a disk tool can give a typo: "there is nothing
here" is a plausible result, so nothing tells the user to look again. The
--jsoncase is the one that hurts downstream — a script cannot tell anempty report from a mistyped path.
The walk swallows it on purpose one layer down:
walk_rootskips entriesjwalkreturns an error for, which is right for the permission errors itwas written for and wrong for a root that was never there.
Two small changes in the CLI, and they can be one PR:
#[arg(required = true)], ornum_args = 1..)so clap prints the usage error itself;
wrong, rather than reporting an empty scan.
A non-zero exit code for the second case matters as much as the message.
crates/diskern-cli/src/main.rs:22·crates/diskern-cli/src/main.rs:200