mirror of
https://github.com/sharkdp/hexyl.git
synced 2026-10-28 08:05:52 +00:00
skip option error messages and display offset
This commit is contained in:
1 parent
133fdd9156
commit
c336259159
2 files changed
+17
-6
No files matched your search
+13
-2
@@ -18,10 +18,21 @@ impl<'a> Read for Input<'a> {
|
||||
impl<'a> Seek for Input<'a> {
|
||||
fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
|
||||
match *self {
|
||||
Input::File(ref mut file) => file.seek(pos),
|
||||
Input::File(ref mut file) => {
|
||||
let seek_res = file.seek(pos);
|
||||
if let Err(Some(29)) = seek_res.as_ref().map_err(|err| err.raw_os_error()) {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"Using '--seek' is not supported when using a pipe",
|
||||
)
|
||||
.into());
|
||||
};
|
||||
dbg!(&seek_res);
|
||||
seek_res
|
||||
}
|
||||
Input::Stdin(_) => Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"not supported by stdin-input",
|
||||
"Using '--seek' is not supported when reading from STDIN",
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user