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
This commit is contained in:
1 parent
3a9127f103
commit
97558276e4
42 files changed
+555
-500
No files matched your search
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "ot-main.h"
|
||||
#include "ot-builtins.h"
|
||||
#include "ostree.h"
|
||||
#include "libgsystem.h"
|
||||
@@ -56,7 +57,7 @@ on_checksum_received (GObject *obj,
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_builtin_checksum (int argc, char **argv, OstreeRepo *repo, GCancellable *cancellable, GError **error)
|
||||
ostree_builtin_checksum (int argc, char **argv, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
GOptionContext *context;
|
||||
gboolean ret = FALSE;
|
||||
@@ -64,9 +65,8 @@ ostree_builtin_checksum (int argc, char **argv, OstreeRepo *repo, GCancellable *
|
||||
AsyncChecksumData data = { 0, };
|
||||
|
||||
context = g_option_context_new ("PATH - Checksum a file or directory");
|
||||
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_NO_REPO, NULL, cancellable, error))
|
||||
goto out;
|
||||
|
||||
if (argc > 1)
|
||||
|
||||
Reference in new issue
Block a user