Closed aqw closed 1 month ago
This is an informative distinction and programmatically reliable, since return 1
in your suggestion is easier than catching 0
in stderr and No assets matching the filter(s) were found
in stdout.
+1 in principle
I cannot think of an error in onyo get that still leads to a successful query.
That may be the case WRT to validation. In get we might easily stumble upon a file, that's not an asset but also not onyo-ignored yet (there's an error message for it, but it has no effect on the exit code as of now - regardless of switches). Similar things could happen with any sort of validation failure or invalid asset files.
Hmm... I see your point. Maybe this behavior will change as we approach fsck
, but our general idea has been to abort fully if the repo or asset is invalid in any way.
I think for now I would like to continue with that assumption, until we load the headspace of fsck
and "what guarantees are we making by even invoking onyo".
If +1 in principal... I have opened #683 :-D
Currently,
onyo get
returns1
only if there is an error.I propose that we match
grep
's behavior, which allows for some useful functionality.From
grep
's manpage:I propose that
onyo get
:0
if matches were found1
if no matches found (i.e. no results)2
for errorWe already have
--quiet
as part ofonyo --quiet
I cannot think of an error in
onyo get
that still leads to a successful query. So we can ignore that aspect of their functionality.The real value of
--quiet
is to abort searching early once a match is found. But that optimization (and its architectural tradeoffs) is not within the scope of this issue. If desired, a separate issue should be opened to track that.In the end, this functionality would allow for scripts such as the following: