fix(tools): h5rs diff names its options as h5diff does

-c meant "list at most N differences" in h5rs, but in h5diff -c is
--compare (a flag) and the count is -n/--count=N, so a script moved over
from h5diff behaved differently: `h5diff -r -c 2 A B` exits 2 (the 2 is
taken as a file name) while h5rs exited 1.

The count is now -n/--count, -c/--compare is accepted (h5rs always lists
objects that are not comparable), and the --count=N, --delta=D,
--relative=R forms are accepted; exit codes equal h5diff's on 7 cases.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
osobh
2026-09-26 01:18:56 -05:00
co-authored by Claude Opus 5.5
parent b5e43bacd7
commit 386bd1d41e
5 changed files with 70 additions and 9 deletions
+12 -5
View File
@@ -11,30 +11,37 @@ pub struct Out<'a> {
/// The arguments after the subcommand name.
pub struct Args {
cmd: &'static str,
rest: std::vec::IntoIter<String>,
rest: std::collections::VecDeque<String>,
}
impl Args {
pub fn new(cmd: &'static str, rest: Vec<String>) -> Self {
Self {
cmd,
rest: rest.into_iter(),
rest: rest.into(),
}
}
#[allow(clippy::should_implement_trait)]
pub fn next(&mut self) -> Option<String> {
self.rest.next()
self.rest.pop_front()
}
/// Put an option and its value back, to be read next (for the
/// `--name=value` form).
pub fn push_front(&mut self, name: String, value: String) {
self.rest.push_front(value);
self.rest.push_front(name);
}
/// The value after an option such as `--max-bytes`.
pub fn value(&mut self) -> Option<String> {
self.rest.next()
self.rest.pop_front()
}
/// A numeric option value.
pub fn number<T: std::str::FromStr>(&mut self) -> Option<T> {
self.rest.next().and_then(|s| s.parse().ok())
self.rest.pop_front().and_then(|s| s.parse().ok())
}
/// Report a usage problem; exit status 2.