After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 705903 - Better parsing for global ostree options
Better parsing for global ostree options
Status: RESOLVED FIXED
Product: ostree
Classification: Infrastructure
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: OSTree maintainer(s)
OSTree maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2013-08-13 12:16 UTC by Stef Walter
Modified: 2013-08-14 05:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Better parsing for global ostree options (5.57 KB, patch)
2013-08-13 12:16 UTC, Stef Walter
accepted-commit_now Details | Review
Better parsing for global ostree options (11.19 KB, patch)
2013-08-13 12:29 UTC, Stef Walter
committed Details | Review

Description Stef Walter 2013-08-13 12:16:49 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.
Comment 1 Stef Walter 2013-08-13 12:16:52 UTC
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
Comment 2 Stef Walter 2013-08-13 12:29:01 UTC
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
Comment 3 Colin Walters 2013-08-13 23:03:30 UTC
Review of attachment 251468 [details] [review]:

Yeah, I really strugged with this.  Systemd has some useful ideas here, but this code looks good.
Comment 4 Colin Walters 2013-08-13 23:09:57 UTC
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.
Comment 5 Stef Walter 2013-08-14 05:55:41 UTC
Attachment 251469 [details] pushed as 1f8c7a2 - Better parsing for global ostree options