GNOME Bugzilla – Bug 740295
Refactor command-line parsing
Last modified: 2014-11-25 00:38:48 UTC
Created attachment 290890 [details] [review] Proposed patch This was just a weekend hack. I refactored OSTree's command-line parsing to try and better utilize GOptionContext. Primary goal was to show the global options in the help output (for the sake of newbies like me), but a nice side-effect is it eliminated most of the manual option parsing. Still testing this, but it seems okay so far. Here's a sample: $ ostree admin --help Usage: ostree admin [OPTION...] --print-current-dir|COMMAND Builtin "admin" Commands: cleanup config-diff deploy init-fs instutil os-init status switch undeploy upgrade Help Options: -h, --help Show help options Application Options: --sysroot=PATH Create a new OSTree sysroot at PATH -v, --verbose Print debug information during command processing --version Print version information and exit
Review of attachment 290890 [details] [review]: Wow, this looks pretty awesome. I think I see how this works, we create an option context which knows about the subcommands. The code does look nicer. I tried applying this to master but hit some conflicts, can you rebase?
That's odd, I rechecked and my git repo was already up-to-date. Are you maybe missing my manpage/option tweaks? That's the latest commit on master as of this morning. Basically the new "parse" functions have all the smarts. They both list and handle the global options, and return back a new OstreeRepo or OstreeSysroot instance accordingly.
Caught that the GMainContext in ostree_usage() is leaking. Fixed locally.
Created attachment 291417 [details] [review] Revised patch A bit more polish.
Review of attachment 291417 [details] [review]: This looks good to me.
Thanks for the review! https://git.gnome.org/browse/ostree/commit/?id=97558276e4f855442337be01abc8f90cf0dd1810