-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get on non-existing key will panic #14
Comments
See #14. This replaces the panic with a nice clean error message. Not yet closing the issue, though, because as discussed there the interface we want is what `git config` does in this situation: prints no output, but also prints nothing to stderr, and just exits with a failure status.
OK, fixed! And released the fix, in v0.2.3. Thanks again @liubin for the report. |
A little bit more history on this issue, history that I (re-)discovered while doing the small survey of uses of In
That behavior isn't awful. It's the same behavior as
But it wasn't great either. It's fine for Then in commit 9c4fe0b, I upgraded the I'm happy with the new
So I don't plan to change it back to printing "null". But I will add a mention of this to the v0.2.1 changelog, now that I know about the change. |
For more details, see this comment on the mentioned issue: #14 (comment)
Originally posted by @gnprice in #13 (comment):
Interesting, can you say more about the motivation for this subcommand [
toml check
]?I think the way I'd expect to handle this use case in a CLI is by using the "get" command, and just redirecting the output to
/dev/null
if I don't actually want it.Looking at
git config
— which I find to be a good source of inspiration for this command's interface, as mentioned in the README — it looks like that's exactly what it does. There's no specialized "check" action ingit config --help
, but instead there's this:I think that'd work well for the
toml
command, too.Looks like our current behavior in
toml get
if there's no data at the given path is to panic, eep:Or after upgrading dependencies, the panic is a bit less noisy but still a panic:
It's panicking in the
walk_tpath
function.So I think basically what we want here is to take your
check_exists
function [from #13], which is a non-panicky version ofwalk_tpath
, and put that logic inwalk_tpath
so thattoml get
can give a clean error result (just likegit config
does) instead of panicking.The text was updated successfully, but these errors were encountered: