diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2014-11-14 14:00:13 -0500 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2014-11-24 19:36:07 -0500 |
commit | 97558276e4f855442337be01abc8f90cf0dd1810 (patch) | |
tree | cadf8676b5163ed41c810335a57ddd4cf0e95f26 /src/ostree/ot-builtin-reset.c | |
parent | 3a9127f103df3f4574aa441e044447cf36358578 (diff) | |
download | ostree-97558276e4f855442337be01abc8f90cf0dd1810.tar.gz |
Refactor command-line parsing
Refactor command-line parsing to better utilize GOptionContext. This
eliminates most of the manual parsing and global options are now shown
in the help output.
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
https://bugzilla.gnome.org/show_bug.cgi?id=740295
Diffstat (limited to 'src/ostree/ot-builtin-reset.c')
-rw-r--r-- | src/ostree/ot-builtin-reset.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/ostree/ot-builtin-reset.c b/src/ostree/ot-builtin-reset.c index a2ab429e..0a72846d 100644 --- a/src/ostree/ot-builtin-reset.c +++ b/src/ostree/ot-builtin-reset.c @@ -22,6 +22,7 @@ #include "config.h" +#include "ot-main.h" #include "ot-builtins.h" #include "ostree.h" #include "otutil.h" @@ -83,11 +84,11 @@ out: gboolean ostree_builtin_reset (int argc, char **argv, - OstreeRepo *repo, GCancellable *cancellable, GError **error) { GOptionContext *context; + gs_unref_object OstreeRepo *repo = NULL; gboolean ret = FALSE; const char *ref; const char *target = NULL; @@ -95,9 +96,8 @@ ostree_builtin_reset (int argc, gs_free gchar *checksum = NULL; context = g_option_context_new ("[ARG] - Reset a ref to a previous commit"); - g_option_context_add_main_entries (context, options, NULL); - if (!g_option_context_parse (context, &argc, &argv, error)) + if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error)) goto out; if (argc <= 2) @@ -130,6 +130,7 @@ ostree_builtin_reset (int argc, out: if (context) g_option_context_free (context); - ostree_repo_abort_transaction (repo, cancellable, NULL); + if (repo) + ostree_repo_abort_transaction (repo, cancellable, NULL); return ret; } |