GNOME Bugzilla – Bug 705903
Better parsing for global ostree options
Last modified: 2013-08-14 05:55:45 UTC
The current way that ostree accepts global arguments is quite irritating, forcing you to do things like specify --repo when you just want --help and several other things. It is hard to do global options for a sub-command based tool. Attaching a patch based on what I did in p11-kit. Although it's not super succinct I believe it covers all the bases and gives the expected experience.
Created attachment 251468 [details] [review] Better parsing for global ostree options * Specifying global options after the command for a more natural: # ostree commit --repo=/path/to/repo ... * Support asking for --help without --repo # ostree commit --help * Support short form of -h * Support specifying --repo without equals sign # ostree --repo /path/to/repo commit ... * Support global --help and -h # ostree --help
Created attachment 251469 [details] [review] Better parsing for global ostree options * Specifying global options after the command for a more natural: # ostree commit --repo=/path/to/repo ... * Support asking for --help without --repo # ostree commit --help * Support short form of -h * Support specifying --repo without equals sign # ostree --repo /path/to/repo commit ... * Support global --help and -h # ostree --help * Ditto for ostree admin sub commands * Removed some leaky code
Review of attachment 251468 [details] [review]: Yeah, I really strugged with this. Systemd has some useful ideas here, but this code looks good.
Review of attachment 251469 [details] [review]: Ah, this one is even better. I wonder if we should make a little reusable GLib library for option parsing with subcommands, or improve GLib's. But this is good for now.
Attachment 251469 [details] pushed as 1f8c7a2 - Better parsing for global ostree options