ostree: move flags into command struct, pass down through builtins
authorRuixin Bao <peter.bao@mail.utoronto.ca>
Tue, 17 Oct 2017 17:25:04 +0000 (17:25 +0000)
committerAtomic Bot <atomic-devel@projectatomic.io>
Fri, 20 Oct 2017 12:59:33 +0000 (12:59 +0000)
This is a similar approach as
https://github.com/projectatomic/rpm-ostree/commit/12c34bb2491a07079c911ef26401fee939e5573c.

One thing to note is when we parse the admin related functions,
we still keep the old admin related flags, and added a new parameter
to represent the command struct.

This allows us to identify the caller of the function, making it
easier for us to possibly deduplicate the subcommand handling in
the future. A similar approach is done in rpm-ostree:
https://github.com/projectatomic/rpm-ostree/commit/83aeb018c1012c7a43783c09b74ec71bc9c45826

This also makes it easier for us to change the prototype of the function.
If we want to add something new in the future, we won't need to touch every prototype.

Closes: #1267
Approved by: cgwalters

58 files changed:
src/ostree/main.c
src/ostree/ot-admin-builtin-cleanup.c
src/ostree/ot-admin-builtin-deploy.c
src/ostree/ot-admin-builtin-diff.c
src/ostree/ot-admin-builtin-init-fs.c
src/ostree/ot-admin-builtin-instutil.c
src/ostree/ot-admin-builtin-os-init.c
src/ostree/ot-admin-builtin-set-origin.c
src/ostree/ot-admin-builtin-status.c
src/ostree/ot-admin-builtin-switch.c
src/ostree/ot-admin-builtin-undeploy.c
src/ostree/ot-admin-builtin-unlock.c
src/ostree/ot-admin-builtin-upgrade.c
src/ostree/ot-admin-builtins.h
src/ostree/ot-admin-instutil-builtin-grub2-generate.c
src/ostree/ot-admin-instutil-builtin-selinux-ensure-labeled.c
src/ostree/ot-admin-instutil-builtin-set-kargs.c
src/ostree/ot-admin-instutil-builtins.h
src/ostree/ot-builtin-admin.c
src/ostree/ot-builtin-cat.c
src/ostree/ot-builtin-checkout.c
src/ostree/ot-builtin-checksum.c
src/ostree/ot-builtin-commit.c
src/ostree/ot-builtin-config.c
src/ostree/ot-builtin-create-usb.c
src/ostree/ot-builtin-diff.c
src/ostree/ot-builtin-export.c
src/ostree/ot-builtin-find-remotes.c
src/ostree/ot-builtin-fsck.c
src/ostree/ot-builtin-gpg-sign.c
src/ostree/ot-builtin-init.c
src/ostree/ot-builtin-log.c
src/ostree/ot-builtin-ls.c
src/ostree/ot-builtin-prune.c
src/ostree/ot-builtin-pull-local.c
src/ostree/ot-builtin-pull.c
src/ostree/ot-builtin-refs.c
src/ostree/ot-builtin-remote.c
src/ostree/ot-builtin-reset.c
src/ostree/ot-builtin-rev-parse.c
src/ostree/ot-builtin-show.c
src/ostree/ot-builtin-static-delta.c
src/ostree/ot-builtin-summary.c
src/ostree/ot-builtin-trivial-httpd.c
src/ostree/ot-builtins.h
src/ostree/ot-main.c
src/ostree/ot-main.h
src/ostree/ot-remote-builtin-add-cookie.c
src/ostree/ot-remote-builtin-add.c
src/ostree/ot-remote-builtin-delete-cookie.c
src/ostree/ot-remote-builtin-delete.c
src/ostree/ot-remote-builtin-gpg-import.c
src/ostree/ot-remote-builtin-list-cookies.c
src/ostree/ot-remote-builtin-list.c
src/ostree/ot-remote-builtin-refs.c
src/ostree/ot-remote-builtin-show-url.c
src/ostree/ot-remote-builtin-summary.c
src/ostree/ot-remote-builtins.h

index ef8f1f8af383dd934fda125719d1b85f8226806d..4ae261d681d7c4c70923ed4acaa34ab47b80e20b 100644 (file)
 #include "ot-builtins.h"
 
 static OstreeCommand commands[] = {
-  { "admin", ostree_builtin_admin ,
+  /* Note: all admin related commands have
+   * no_repo as their command flag, but each
+   * admin command may have their own
+   * admin flag
+   */
+  { "admin", OSTREE_BUILTIN_FLAG_NO_REPO,
+    ostree_builtin_admin,
     "Commands that needs admin privilege" },
-  { "cat", ostree_builtin_cat,
+  { "cat", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_cat,
     "Concatenate contents of files"},
-  { "checkout", ostree_builtin_checkout,
+  { "checkout", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_checkout,
     "Check out a commit into a filesystem tree" },
-  { "checksum", ostree_builtin_checksum,
+  { "checksum", OSTREE_BUILTIN_FLAG_NO_REPO,
+    ostree_builtin_checksum,
     "Checksum a file or directory" },
-  { "commit", ostree_builtin_commit,
+  { "commit", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_commit,
     "Commit a new revision" },
-  { "config", ostree_builtin_config,
+  { "config", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_config,
     "Change repo configuration settings" },
-  { "diff", ostree_builtin_diff,
+  { "diff", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_diff,
     "Compare directory TARGETDIR against revision REV"},
-  { "export", ostree_builtin_export,
+  { "export", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_export,
     "Stream COMMIT to stdout in tar format" },
 #ifdef OSTREE_ENABLE_EXPERIMENTAL_API
-  { "find-remotes", ostree_builtin_find_remotes,
+  { "find-remotes", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_find_remotes,
     "Find remotes to serve the given refs" },
-  { "create-usb", ostree_builtin_create_usb,
+  { "create-usb", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_create_usb,
     "Copy the refs to a USB stick" },
 #endif
-  { "fsck", ostree_builtin_fsck,
+  { "fsck", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_fsck,
     "Check the repository for consistency" },
-  { "gpg-sign", ostree_builtin_gpg_sign,
+  { "gpg-sign", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_gpg_sign,
     "Sign a commit" },
-  { "init", ostree_builtin_init,
+  { "init", OSTREE_BUILTIN_FLAG_NO_CHECK,
+    ostree_builtin_init,
     "Initialize a new empty repository" },
-  { "log", ostree_builtin_log,
+  { "log", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_log,
     "Show log starting at commit or ref" },
-  { "ls", ostree_builtin_ls,
+  { "ls", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_ls,
     "List file paths" },
-  { "prune", ostree_builtin_prune,
+  { "prune", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_prune,
     "Search for unreachable objects" },
-  { "pull-local", ostree_builtin_pull_local,
+  { "pull-local", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_pull_local,
     "Copy data from SRC_REPO" },
 #ifdef HAVE_LIBCURL_OR_LIBSOUP
-  { "pull", ostree_builtin_pull,
+  { "pull", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_pull,
     "Download data from remote repository" },
 #endif
-  { "refs", ostree_builtin_refs,
+  { "refs", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_refs,
     "List refs" },
-  { "remote", ostree_builtin_remote,
+  { "remote", OSTREE_BUILTIN_FLAG_NO_REPO,
+    ostree_builtin_remote,
     "Remote commands that may involve internet access" },
-  { "reset", ostree_builtin_reset,
+  { "reset", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_reset,
     "Reset a REF to a previous COMMIT" },
-  { "rev-parse", ostree_builtin_rev_parse,
+  { "rev-parse", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_rev_parse,
     "Output the target of a rev" },
-  { "show", ostree_builtin_show,
+  { "show", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_show,
     "Output a metadata object" },
-  { "static-delta", ostree_builtin_static_delta,
+  { "static-delta", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_static_delta,
     "Static delta related commands" },
-  { "summary", ostree_builtin_summary,
+  { "summary", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_summary,
     "Manage summary metadata" },
 #if defined(HAVE_LIBSOUP) && defined(BUILDOPT_ENABLE_TRIVIAL_HTTPD_CMDLINE)
-  { "trivial-httpd", ostree_builtin_trivial_httpd,
+  { "trivial-httpd", OSTREE_BUILTIN_FLAG_NONE,
+    ostree_builtin_trivial_httpd,
     NULL },
 #endif
   { NULL }
index 954f8d8aeaefa07c0eb322912e524a31424c561d..bc7a724bde641da489088e50aeb4d430461ea408 100644 (file)
@@ -38,7 +38,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_cleanup (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_admin_builtin_cleanup (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeSysroot) sysroot = NULL;
@@ -48,7 +48,7 @@ ot_admin_builtin_cleanup (int argc, char **argv, GCancellable *cancellable, GErr
 
   if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
                                           OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
-                                          &sysroot, cancellable, error))
+                                          invocation, &sysroot, cancellable, error))
     goto out;
 
   if (!ostree_sysroot_cleanup (sysroot, cancellable, error))
index 10ac57de442915224f255c2cd5d1dff5e35394ef..6bfc09ee98456368fa5bd33a79eef07b36653635 100644 (file)
@@ -60,7 +60,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_deploy (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   __attribute__((cleanup(_ostree_kernel_args_cleanup))) OstreeKernelArgs *kargs = NULL;
 
@@ -70,7 +70,7 @@ ot_admin_builtin_deploy (int argc, char **argv, GCancellable *cancellable, GErro
   g_autoptr(OstreeSysroot) sysroot = NULL;
   if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
                                           OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
-                                          &sysroot, cancellable, error))
+                                          invocation, &sysroot, cancellable, error))
     return FALSE;
 
   if (argc < 2)
index 6afe4fae6bef92d99f1f1ddd2938ecd2c2216451..ec8f692e88abd0764fe2dd1239b42f2df07f39dc 100644 (file)
@@ -41,7 +41,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_admin_builtin_diff (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeSysroot) sysroot = NULL;
@@ -60,7 +60,7 @@ ot_admin_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError
 
   if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
                                           OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
-                                          &sysroot, cancellable, error))
+                                          invocation, &sysroot, cancellable, error))
     goto out;
 
   if (!ot_admin_require_booted_deployment_or_osname (sysroot, opt_osname,
index 3ef9017f5ce1bdf5088e02da1b3a10426d6d631d..e1c0e4396dde6528c013d9ba43da45530098698a 100644 (file)
@@ -38,15 +38,15 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_init_fs (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_admin_builtin_init_fs (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = g_option_context_new ("PATH - Initialize a root filesystem");
 
   if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
                                           OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER |
-                                           OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED |
-                                           OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT,
-                                          NULL, cancellable, error))
+                                          OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED |
+                                          OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT,
+                                          invocation, NULL, cancellable, error))
     return FALSE;
 
   if (argc < 2)
index 428c0a2cd2c8287e3c4a591fdf507af30f5979c0..0ee3b3f2bf9a49edbc1145d7feb33e8581384a30 100644 (file)
 
 #include <glib/gi18n.h>
 
-typedef struct {
-  const char *name;
-  gboolean (*fn) (int argc, char **argv, GCancellable *cancellable, GError **error);
-  const char *description;
-} OstreeAdminInstUtilCommand;
-
-static OstreeAdminInstUtilCommand admin_instutil_subcommands[] = {
+static OstreeCommand admin_instutil_subcommands[] = {
 #ifdef HAVE_SELINUX
-  { "selinux-ensure-labeled", ot_admin_instutil_builtin_selinux_ensure_labeled,
+  { "selinux-ensure-labeled", OSTREE_BUILTIN_FLAG_NO_REPO,
+    ot_admin_instutil_builtin_selinux_ensure_labeled,
     "Relabel all or part of a deployment" },
 #endif
-  { "set-kargs", ot_admin_instutil_builtin_set_kargs,
+  { "set-kargs", OSTREE_BUILTIN_FLAG_NO_REPO,
+    ot_admin_instutil_builtin_set_kargs,
     "Set new kernel command line arguments(Not stable)"  },
-  { "grub2-generate", ot_admin_instutil_builtin_grub2_generate,
+  { "grub2-generate", OSTREE_BUILTIN_FLAG_NO_REPO,
+    ot_admin_instutil_builtin_grub2_generate,
     "Generate GRUB2 configuration from given BLS entries" },
-  { NULL, NULL, NULL }
+  { NULL, 0, NULL, NULL }
 };
 
 static GOptionContext *
 ostree_admin_instutil_option_context_new_with_commands (void)
 {
-  OstreeAdminInstUtilCommand *command = admin_instutil_subcommands;
+  OstreeCommand *command = admin_instutil_subcommands;
   GOptionContext *context = g_option_context_new ("COMMAND");
 
   g_autoptr(GString) summary = g_string_new ("Builtin \"admin instutil\" Commands:");
@@ -69,7 +66,7 @@ ostree_admin_instutil_option_context_new_with_commands (void)
 }
 
 gboolean
-ot_admin_builtin_instutil (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_admin_builtin_instutil (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   const char *subcommand_name = NULL;
   int in, out;
@@ -97,7 +94,7 @@ ot_admin_builtin_instutil (int argc, char **argv, GCancellable *cancellable, GEr
 
   argc = out;
 
-  OstreeAdminInstUtilCommand *subcommand = admin_instutil_subcommands;
+  OstreeCommand *subcommand = admin_instutil_subcommands;
   while (subcommand->name)
     {
       if (g_strcmp0 (subcommand_name, subcommand->name) == 0)
@@ -113,7 +110,7 @@ ot_admin_builtin_instutil (int argc, char **argv, GCancellable *cancellable, GEr
       /* This will not return for some options (e.g. --version). */
       if (ostree_admin_option_context_parse (context, NULL, &argc, &argv,
                                              OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT,
-                                             NULL, cancellable, error))
+                                             invocation, NULL, cancellable, error))
         {
           if (subcommand_name == NULL)
             {
@@ -135,7 +132,8 @@ ot_admin_builtin_instutil (int argc, char **argv, GCancellable *cancellable, GEr
   g_autofree char *prgname = g_strdup_printf ("%s %s", g_get_prgname (), subcommand_name);
   g_set_prgname (prgname);
 
-  if (!subcommand->fn (argc, argv, cancellable, error))
+  OstreeCommandInvocation sub_invocation = { .command = subcommand };
+  if (!subcommand->fn (argc, argv, &sub_invocation, cancellable, error))
     return FALSE;
 
   return TRUE;
index b325ab3200840096b6496a6a6a39c48e65ab02a6..a6a11f99e61a6bee343e776a00583308c3930463 100644 (file)
@@ -38,7 +38,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_os_init (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_admin_builtin_os_init (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeSysroot) sysroot = NULL;
@@ -49,7 +49,7 @@ ot_admin_builtin_os_init (int argc, char **argv, GCancellable *cancellable, GErr
 
   if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
                                           OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
-                                          &sysroot, cancellable, error))
+                                          invocation, &sysroot, cancellable, error))
     goto out;
 
   if (!ostree_sysroot_ensure_initialized (sysroot, cancellable, error))
index 0332d882ab9190bb97316c270a67e21914719880..0f6fd2591e4445b18dea929b1b74cf81d663e729 100644 (file)
@@ -45,7 +45,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_set_origin (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_admin_builtin_set_origin (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
   g_autoptr(GOptionContext) context = NULL;
@@ -60,7 +60,7 @@ ot_admin_builtin_set_origin (int argc, char **argv, GCancellable *cancellable, G
 
   if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
                                           OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
-                                          &sysroot, cancellable, error))
+                                          invocation, &sysroot, cancellable, error))
     goto out;
 
   if (argc < 3)
index f076c592ad85f3ccd10694932c8257564e305c41..b88c2fbad6f809c32d83c588412429f0a43ab750 100644 (file)
@@ -85,7 +85,7 @@ out:
 }
 
 gboolean
-ot_admin_builtin_status (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_admin_builtin_status (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeSysroot) sysroot = NULL;
@@ -104,7 +104,7 @@ ot_admin_builtin_status (int argc, char **argv, GCancellable *cancellable, GErro
 
   if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
                                           OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
-                                          &sysroot, cancellable, error))
+                                          invocation, &sysroot, cancellable, error))
     goto out;
 
   if (!ostree_sysroot_get_repo (sysroot, &repo, cancellable, error))
index 56e731b210a8e202cfda6a68ed4ae2948d051481..1b1082d5f55edd1cc9d3b593efd476865422b8d0 100644 (file)
@@ -44,14 +44,14 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_switch (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_admin_builtin_switch (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context =
     g_option_context_new ("REF - Construct new tree from REF and deploy it");
   g_autoptr(OstreeSysroot) sysroot = NULL;
   if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
                                           OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
-                                          &sysroot, cancellable, error))
+                                          invocation, &sysroot, cancellable, error))
     return FALSE;
 
   if (argc < 2)
index 6ca8e3a32684e42fb668f0cc8147055622a9095f..3bddd6cb3306c33b3d5a470ad59e6c712e8c8398 100644 (file)
@@ -37,7 +37,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_undeploy (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_admin_builtin_undeploy (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeSysroot) sysroot = NULL;
@@ -50,7 +50,7 @@ ot_admin_builtin_undeploy (int argc, char **argv, GCancellable *cancellable, GEr
 
   if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
                                           OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
-                                          &sysroot, cancellable, error))
+                                          invocation, &sysroot, cancellable, error))
     return FALSE;
 
   if (argc < 2)
index 1b6d9203cee09e76d248122770138e766e90161e..cb3598fddb9d5d868f01947fffc4a872e69ac77d 100644 (file)
@@ -43,7 +43,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_unlock (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_admin_builtin_unlock (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
   g_autoptr(GOptionContext) context = NULL;
@@ -55,7 +55,7 @@ ot_admin_builtin_unlock (int argc, char **argv, GCancellable *cancellable, GErro
 
   if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
                                           OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
-                                          &sysroot, cancellable, error))
+                                          invocation, &sysroot, cancellable, error))
     goto out;
   
   if (argc > 1)
index dfda4d5fccd9f743dbff66b977ac5671d95f823b..c0542f3e160cbf874da9df2d3a6bcf66ef0241a2 100644 (file)
@@ -54,14 +54,14 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_builtin_upgrade (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_admin_builtin_upgrade (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = g_option_context_new ("Construct new tree from current origin and deploy it, if it changed");
 
   g_autoptr(OstreeSysroot) sysroot = NULL;
   if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
                                           OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
-                                          &sysroot, cancellable, error))
+                                          invocation, &sysroot, cancellable, error))
     return FALSE;
 
   if (opt_pull_only && opt_deploy_only)
index 75cd14484acd23f624e06005fbc0038fd9227d1e..1d62daf8d9acbdfd46534b694d87a744b66b2d2f 100644 (file)
 
 G_BEGIN_DECLS
 
-gboolean ot_admin_builtin_selinux_ensure_labeled (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_admin_builtin_os_init (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_admin_builtin_install (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_admin_builtin_instutil (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_admin_builtin_init_fs (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_admin_builtin_undeploy (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_admin_builtin_deploy (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_admin_builtin_cleanup (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_admin_builtin_unlock (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_admin_builtin_status (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_admin_builtin_set_origin (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_admin_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_admin_builtin_switch (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_admin_builtin_upgrade (int argc, char **argv, GCancellable *cancellable, GError **error);
+#define BUILTINPROTO(name) gboolean ot_admin_builtin_ ## name (int argc, char **argv, \
+                                                               OstreeCommandInvocation *invocation, \
+                                                               GCancellable *cancellable, GError **error)
+
+BUILTINPROTO(selinux_ensure_labeled);
+BUILTINPROTO(os_init);
+BUILTINPROTO(install);
+BUILTINPROTO(instutil);
+BUILTINPROTO(init_fs);
+BUILTINPROTO(undeploy);
+BUILTINPROTO(deploy);
+BUILTINPROTO(cleanup);
+BUILTINPROTO(unlock);
+BUILTINPROTO(status);
+BUILTINPROTO(set_origin);
+BUILTINPROTO(diff);
+BUILTINPROTO(switch);
+BUILTINPROTO(upgrade);
+
+#undef BUILTINPROTO
 
 G_END_DECLS
index 64d2ae2a4e619dd24d229b7b21a2cf4653bc7079..a7eb0d4ff2dc277bdc8c1dfd5268f559d11a9429 100644 (file)
@@ -38,7 +38,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_instutil_builtin_grub2_generate (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_admin_instutil_builtin_grub2_generate (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
   guint bootversion;
@@ -49,7 +49,7 @@ ot_admin_instutil_builtin_grub2_generate (int argc, char **argv, GCancellable *c
 
   if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
                                           OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
-                                          &sysroot, cancellable, error))
+                                          invocation, &sysroot, cancellable, error))
     goto out;
 
   if (argc >= 2)
index 135bcf42bc4e444d7481c06d1effdb493009bc53..ca3fab174f6abdb3d032e933f34191da26ed9f63 100644 (file)
@@ -183,7 +183,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
   const char *policy_name;
@@ -200,7 +200,7 @@ ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, GCancel
 
   if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
                                           OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
-                                          &sysroot, cancellable, error))
+                                          invocation, &sysroot, cancellable, error))
     goto out;
 
   deployments = ostree_sysroot_get_deployments (sysroot);
index f8db6c6bdb814fa0d84676092dec521ea5d0de90..7419581c1db076c9d85be8dd5028e7eb183c3458 100644 (file)
@@ -48,7 +48,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ot_admin_instutil_builtin_set_kargs (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_admin_instutil_builtin_set_kargs (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
   guint i;
@@ -62,7 +62,7 @@ ot_admin_instutil_builtin_set_kargs (int argc, char **argv, GCancellable *cancel
 
   if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
                                           OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER | OSTREE_ADMIN_BUILTIN_FLAG_UNLOCKED,
-                                          &sysroot, cancellable, error))
+                                          invocation, &sysroot, cancellable, error))
     goto out;
 
   deployments = ostree_sysroot_get_deployments (sysroot);
index 748a79388d8e419c92c562b45622f4fb45a87af9..b0277e71cb4668a38d71f14b70450d23e42019f2 100644 (file)
@@ -23,8 +23,8 @@
 
 G_BEGIN_DECLS
 
-gboolean ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_admin_instutil_builtin_set_kargs (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_admin_instutil_builtin_grub2_generate (int argc, char **argv, GCancellable *cancellable, GError **error);
+gboolean ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error);
+gboolean ot_admin_instutil_builtin_set_kargs (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error);
+gboolean ot_admin_instutil_builtin_grub2_generate (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error);
 
 G_END_DECLS
index ba9dc28d4e9220ba4ca29bb94a3e13789be6a8d4..17033ecf3b4950f22d09d727d08b18f6e3b3c1a9 100644 (file)
 
 #include <glib/gi18n.h>
 
-typedef struct {
-  const char *name;
-  gboolean (*fn) (int argc, char **argv, GCancellable *cancellable, GError **error);
-  const char *description;
-} OstreeAdminCommand;
-
-static OstreeAdminCommand admin_subcommands[] = {
-  { "cleanup", ot_admin_builtin_cleanup,
+static OstreeCommand admin_subcommands[] = {
+  { "cleanup", OSTREE_BUILTIN_FLAG_NO_REPO,
+    ot_admin_builtin_cleanup,
     "Delete untagged deployments and repository objects" },
-  { "config-diff", ot_admin_builtin_diff,
+  { "config-diff", OSTREE_BUILTIN_FLAG_NO_REPO,
+    ot_admin_builtin_diff,
     "Diff current /etc configuration versus default" },
-  { "deploy", ot_admin_builtin_deploy,
+  { "deploy", OSTREE_BUILTIN_FLAG_NO_REPO,
+    ot_admin_builtin_deploy,
     "Checkout revision REFSPEC as the new default deployment" },
-  { "init-fs", ot_admin_builtin_init_fs,
+  { "init-fs", OSTREE_BUILTIN_FLAG_NO_REPO,
+     ot_admin_builtin_init_fs,
     "Initialize a root filesystem" },
-  { "instutil", ot_admin_builtin_instutil,
+  { "instutil", OSTREE_BUILTIN_FLAG_NO_REPO,
+    ot_admin_builtin_instutil,
     "Provide instutil commands, allow admin to change boot configuration and relabel selinux " },
-  { "os-init", ot_admin_builtin_os_init,
+  { "os-init", OSTREE_BUILTIN_FLAG_NO_REPO,
+    ot_admin_builtin_os_init,
     "Initialize empty state for given operating system" },
-  { "set-origin", ot_admin_builtin_set_origin,
+  { "set-origin", OSTREE_BUILTIN_FLAG_NO_REPO,
+    ot_admin_builtin_set_origin,
     "Set Origin and create a new origin file" },
-  { "status", ot_admin_builtin_status,
+  { "status", OSTREE_BUILTIN_FLAG_NO_REPO,
+    ot_admin_builtin_status,
     "List deployments" },
-  { "switch", ot_admin_builtin_switch,
+  { "switch", OSTREE_BUILTIN_FLAG_NO_REPO,
+    ot_admin_builtin_switch,
     "Construct new tree from REF and deploy it" },
-  { "undeploy", ot_admin_builtin_undeploy,
+  { "undeploy", OSTREE_BUILTIN_FLAG_NO_REPO,
+    ot_admin_builtin_undeploy,
     "Delete deployment INDEX" },
-  { "unlock", ot_admin_builtin_unlock,
+  { "unlock", OSTREE_BUILTIN_FLAG_NO_REPO,
+    ot_admin_builtin_unlock,
     "Make the current deployment mutable (as a hotfix or development)" },
-  { "upgrade", ot_admin_builtin_upgrade,
+  { "upgrade", OSTREE_BUILTIN_FLAG_NO_REPO,
+    ot_admin_builtin_upgrade,
     "Construct new tree from current origin and deploy it, if it changed" },
-  { NULL, NULL, NULL }
+  { NULL, 0, NULL, NULL }
 };
 
 static GOptionContext *
 ostree_admin_option_context_new_with_commands (void)
 {
-  OstreeAdminCommand *command = admin_subcommands;
+  OstreeCommand *command = admin_subcommands;
   GOptionContext *context = g_option_context_new ("--print-current-dir|COMMAND");
 
   g_autoptr(GString) summary = g_string_new ("Builtin \"admin\" Commands:");
@@ -86,11 +92,11 @@ ostree_admin_option_context_new_with_commands (void)
 }
 
 gboolean
-ostree_builtin_admin (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_admin (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
   const char *subcommand_name = NULL;
-  OstreeAdminCommand *subcommand;
+  OstreeCommand *subcommand;
   g_autofree char *prgname = NULL;
   int in, out;
 
@@ -141,7 +147,7 @@ ostree_builtin_admin (int argc, char **argv, GCancellable *cancellable, GError *
       /* This will not return for some options (e.g. --version). */
       if (ostree_admin_option_context_parse (context, NULL, &argc, &argv,
                                              OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT,
-                                             NULL, cancellable, error))
+                                             invocation, NULL, cancellable, error))
         {
           if (subcommand_name == NULL)
             {
@@ -164,7 +170,8 @@ ostree_builtin_admin (int argc, char **argv, GCancellable *cancellable, GError *
   prgname = g_strdup_printf ("%s %s", g_get_prgname (), subcommand_name);
   g_set_prgname (prgname);
 
-  if (!subcommand->fn (argc, argv, cancellable, error))
+  OstreeCommandInvocation sub_invocation = { .command = subcommand };
+  if (!subcommand->fn (argc, argv, &sub_invocation, cancellable, error))
     goto out;
  
   ret = TRUE;
index 6f2c466cf8552b547cb8199c5514d527aa977d8c..88bd4fdb26ae6ed4b44df47c8a3275cb7e98ec47 100644 (file)
@@ -55,11 +55,11 @@ cat_one_file (GFile         *f,
 }
 
 gboolean
-ostree_builtin_cat (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_cat (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = g_option_context_new ("COMMIT PATH... - Concatenate contents of files");
   g_autoptr(OstreeRepo) repo = NULL;
-  if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
     return FALSE;
 
   if (argc <= 2)
index e774713e47831b3fe2a9b1298130b039d7ef59ac..79718c9c6ce25a749fc4b945837f36b19f214f08 100644 (file)
@@ -279,7 +279,7 @@ process_many_checkouts (OstreeRepo         *repo,
 }
 
 gboolean
-ostree_builtin_checkout (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_checkout (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeRepo) repo = NULL;
@@ -290,7 +290,7 @@ ostree_builtin_checkout (int argc, char **argv, GCancellable *cancellable, GErro
 
   context = g_option_context_new ("COMMIT [DESTINATION] - Check out a commit into a filesystem tree");
 
-  if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
     goto out;
 
   if (opt_disable_fsync)
index 008c4fe773a8047b121c76210d14ad38064b4b9f..24689ac6dbd8f9facd512084187519cfd671bd1f 100644 (file)
@@ -66,12 +66,12 @@ on_checksum_received (GObject    *obj,
 }
 
 gboolean
-ostree_builtin_checksum (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_checksum (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context =
     g_option_context_new ("PATH - Checksum a file or directory");
   if (!ostree_option_context_parse (context, options, &argc, &argv,
-                                    OSTREE_BUILTIN_FLAG_NO_REPO, NULL, cancellable, error))
+                                    invocation, NULL, cancellable, error))
     return FALSE;
 
   if (argc < 2)
index b10e8d2d220e6467dbf0b468181ee87b31389642..7df1dfe162d8a9dec7f2ba32f2db2115968d864d 100644 (file)
@@ -407,7 +407,7 @@ fill_bindings (OstreeRepo    *repo,
 }
 
 gboolean
-ostree_builtin_commit (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_commit (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeRepo) repo = NULL;
@@ -433,7 +433,7 @@ ostree_builtin_commit (int argc, char **argv, GCancellable *cancellable, GError
 
   context = g_option_context_new ("[PATH] - Commit a new revision");
 
-  if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
     goto out;
 
   if (!ostree_ensure_repo_writable (repo, error))
index 6813305c377d8abfe3b4f1b9ef27b78876b97894..94e36465bcf8680ece3c23488aae93eba507ec85 100644 (file)
@@ -56,7 +56,7 @@ split_key_string (const char   *k,
 }
 
 gboolean
-ostree_builtin_config (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeRepo) repo = NULL;
@@ -70,7 +70,7 @@ ostree_builtin_config (int argc, char **argv, GCancellable *cancellable, GError
 
   context = g_option_context_new ("(get KEY|set KEY VALUE) - Change repo configuration settings");
 
-  if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
     goto out;
 
   if (argc < 2)
index 97b0059adc04f482bd7279f51943de87f4a19228..fcde36c0ee7e00e7cf1e93a47ea1c9fdc3835bc6 100644 (file)
@@ -43,6 +43,7 @@ static GOptionEntry options[] =
 gboolean
 ostree_builtin_create_usb (int            argc,
                            char         **argv,
+                           OstreeCommandInvocation *invocation,
                            GCancellable  *cancellable,
                            GError       **error)
 {
@@ -55,7 +56,7 @@ ostree_builtin_create_usb (int            argc,
   /* Parse options. */
   g_autoptr(OstreeRepo) src_repo = NULL;
 
-  if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &src_repo, cancellable, error))
+  if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &src_repo, cancellable, error))
     return FALSE;
 
   if (argc < 2)
index 465e2506eb5b3fde9dd1dbe24af17775adc3a539..9cd7141b7d1db5b3371f5ed7c1330b2cec20e5b4 100644 (file)
@@ -126,7 +126,7 @@ object_set_total_size (OstreeRepo    *repo,
 }
 
 gboolean
-ostree_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_diff (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
   g_autoptr(GOptionContext) context = NULL;
@@ -142,7 +142,7 @@ ostree_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError **
 
   context = g_option_context_new ("REV TARGETDIR - Compare directory TARGETDIR against revision REV");
 
-  if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
     goto out;
 
   if (argc < 2)
index 7967bf6c7f111b97cb2cd2cdb5b08ececaf66d81..83656d044646a4dda462bb9c4a0c2fc24e6961f4 100644 (file)
@@ -62,7 +62,7 @@ propagate_libarchive_error (GError      **error,
 #endif
 
 gboolean
-ostree_builtin_export (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_export (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeRepo) repo = NULL;
@@ -79,7 +79,7 @@ ostree_builtin_export (int argc, char **argv, GCancellable *cancellable, GError
 
   context = g_option_context_new ("COMMIT - Stream COMMIT to stdout in tar format");
 
-  if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
     goto out;
 
 #ifdef HAVE_LIBARCHIVE  
index daeea38bbe9b52c06d3f466a877a442cfba1dbcb..3cf6c153977d9bb5909a8bb823ba8df75b36f9dc 100644 (file)
@@ -120,6 +120,7 @@ collection_ref_free0 (OstreeCollectionRef *ref)
 gboolean
 ostree_builtin_find_remotes (int            argc,
                              char         **argv,
+                             OstreeCommandInvocation *invocation,
                              GCancellable  *cancellable,
                              GError       **error)
 {
@@ -136,7 +137,7 @@ ostree_builtin_find_remotes (int            argc,
   context = g_option_context_new ("COLLECTION-ID REF [COLLECTION-ID REF...] - Find remotes to serve the given refs");
 
   /* Parse options. */
-  if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
     return FALSE;
 
   if (!ostree_ensure_repo_writable (repo, error))
index 28320985a1b0e5d0f2c446c59dbd64afbe7460e3..81ac32182de007dde9abe6aa64051dc130bfbeae 100644 (file)
@@ -214,13 +214,13 @@ fsck_reachable_objects_from_commits (OstreeRepo            *repo,
 }
 
 gboolean
-ostree_builtin_fsck (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_fsck (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(OstreeRepo) repo = NULL;
   gboolean found_corruption = FALSE;
 
   g_autoptr(GOptionContext) context = g_option_context_new ("- Check the repository for consistency");
-  if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
     return FALSE;
 
   if (!opt_quiet)
index 451d0f468e4e274729abaa76f616a149033c421f..3eeeeb01912c3b7775f81fb5d3e5593d7243cad3 100644 (file)
@@ -200,7 +200,7 @@ out:
 }
 
 gboolean
-ostree_builtin_gpg_sign (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_gpg_sign (int argc, char **argv,OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeRepo) repo = NULL;
@@ -212,7 +212,7 @@ ostree_builtin_gpg_sign (int argc, char **argv, GCancellable *cancellable, GErro
 
   context = g_option_context_new ("COMMIT KEY-ID... - Sign a commit");
 
-  if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
     goto out;
 
   if (argc < 2)
index 7b72620a93cfd148212234a03781ded1dad634b9..c7729e47d9ba12964956485692f3a4d73504e823 100644 (file)
@@ -45,7 +45,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ostree_builtin_init (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_init (int argc, char **argv,OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeRepo) repo = NULL;
@@ -54,7 +54,7 @@ ostree_builtin_init (int argc, char **argv, GCancellable *cancellable, GError **
 
   context = g_option_context_new ("- Initialize a new empty repository");
 
-  if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NO_CHECK, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
     goto out;
 
   if (!ostree_repo_mode_from_string (opt_mode, &mode, error))
index 5fda4ee7c3d81ca2e22021fcf7813d6a364fda82..ee4b37d07ae64fbdd7961377cd07cd7249f9a487 100644 (file)
@@ -82,6 +82,7 @@ out:
 gboolean
 ostree_builtin_log (int           argc,
                     char        **argv,
+                    OstreeCommandInvocation *invocation,
                     GCancellable *cancellable,
                     GError      **error)
 {
@@ -94,7 +95,7 @@ ostree_builtin_log (int           argc,
 
   context = g_option_context_new ("REF - Show log starting at commit or ref");
 
-  if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
     goto out;
 
   if (opt_raw)
index ba22d3c3fa0aae2398b45bea6bd81076f0d56c7b..bababaadc6dd519fbca54df16f2b716b721a1e52 100644 (file)
@@ -240,7 +240,7 @@ print_one_argument (OstreeRepo   *repo,
 }
 
 gboolean
-ostree_builtin_ls (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_ls (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeRepo) repo = NULL;
@@ -251,7 +251,7 @@ ostree_builtin_ls (int argc, char **argv, GCancellable *cancellable, GError **er
 
   context = g_option_context_new ("COMMIT [PATH...] - List file paths");
 
-  if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
     goto out;
 
   if (argc <= 1)
index f5ab596035d5d2a2baa71e85f6bc5e7184be3b69..ab3816bc6335f4c53fbda8313c6f661a9332408d 100644 (file)
@@ -144,11 +144,11 @@ traverse_keep_younger_than (OstreeRepo *repo, const char *checksum,
 }
 
 gboolean
-ostree_builtin_prune (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_prune (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = g_option_context_new ("- Search for unreachable objects");
   g_autoptr(OstreeRepo) repo = NULL;
-  if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
     return FALSE;
 
   if (!opt_no_prune && !ostree_ensure_repo_writable (repo, error))
index 8d4e8d609cf23b72b5378b880a5fddb6c394b375..b907b5aa95e8998e8ab52beae6ed296436e811f5 100644 (file)
@@ -64,7 +64,7 @@ noninteractive_console_progress_changed (OstreeAsyncProgress *progress,
 }
 
 gboolean
-ostree_builtin_pull_local (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_pull_local (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
   g_autoptr(GOptionContext) context = NULL;
@@ -78,7 +78,7 @@ ostree_builtin_pull_local (int argc, char **argv, GCancellable *cancellable, GEr
 
   context = g_option_context_new ("SRC_REPO [REFS...] -  Copy data from SRC_REPO");
 
-  if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
     goto out;
 
   if (!ostree_ensure_repo_writable (repo, error))
index e67d59930f4c3c968ec1a7eb0597b2a9a1a55841..719c4d5b1ae29b6604c0091b6a1d5631a22f4abb 100644 (file)
@@ -143,7 +143,7 @@ noninteractive_console_progress_changed (OstreeAsyncProgress *progress,
 }
 
 gboolean
-ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_pull (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeRepo) repo = NULL;
@@ -157,7 +157,7 @@ ostree_builtin_pull (int argc, char **argv, GCancellable *cancellable, GError **
 
   context = g_option_context_new ("REMOTE [BRANCH...] - Download data from remote repository");
 
-  if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
     goto out;
 
   if (!ostree_ensure_repo_writable (repo, error))
index 1b4ead7d5c77ead12d0777e6e1a99109c75df9ad..68befc74bcc50226ef4929324893d3dcca9ff0bc 100644 (file)
@@ -261,7 +261,7 @@ static gboolean do_ref (OstreeRepo *repo, const char *refspec_prefix, GCancellab
 }
 
 gboolean
-ostree_builtin_refs (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_refs (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
   g_autoptr(GOptionContext) context = NULL;
@@ -270,7 +270,7 @@ ostree_builtin_refs (int argc, char **argv, GCancellable *cancellable, GError **
 
   context = g_option_context_new ("[PREFIX] - List refs");
 
-  if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
     goto out;
 
   if (argc >= 2)
index 0b1c02a201706bbe692ed8c311a64ebb30a70fcf..0be878cc6f7fc78792498ed05d7777f3eeca966a 100644 (file)
 #include "ot-builtins.h"
 #include "ot-remote-builtins.h"
 
-typedef struct {
-  const char *name;
-  gboolean (*fn) (int argc, char **argv, GCancellable *cancellable, GError **error);
-  const char *description;
-} OstreeRemoteCommand;
-
-static OstreeRemoteCommand remote_subcommands[] = {
-  { "add", ot_remote_builtin_add,
+static OstreeCommand remote_subcommands[] = {
+  { "add", OSTREE_BUILTIN_FLAG_NO_REPO,
+    ot_remote_builtin_add,
     "Add a remote repository" },
-  { "delete", ot_remote_builtin_delete,
+  { "delete", OSTREE_BUILTIN_FLAG_NO_REPO,
+    ot_remote_builtin_delete,
     "Delete a remote repository" },
-  { "show-url", ot_remote_builtin_show_url,
+  { "show-url", OSTREE_BUILTIN_FLAG_NONE,
+    ot_remote_builtin_show_url,
     "Show remote repository URL" },
-  { "list", ot_remote_builtin_list,
+  { "list", OSTREE_BUILTIN_FLAG_NONE,
+    ot_remote_builtin_list,
     "List remote repository names" },
-  { "gpg-import", ot_remote_builtin_gpg_import,
+  { "gpg-import", OSTREE_BUILTIN_FLAG_NONE,
+    ot_remote_builtin_gpg_import,
     "Import GPG keys" },
 #ifdef HAVE_LIBSOUP
-  { "add-cookie", ot_remote_builtin_add_cookie,
+  { "add-cookie", OSTREE_BUILTIN_FLAG_NONE,
+    ot_remote_builtin_add_cookie,
     "Add a cookie to remote" },
-  { "delete-cookie", ot_remote_builtin_delete_cookie,
+  { "delete-cookie", OSTREE_BUILTIN_FLAG_NONE,
+    ot_remote_builtin_delete_cookie,
     "Remove one cookie from remote" },
-  { "list-cookies", ot_remote_builtin_list_cookies,
+  { "list-cookies", OSTREE_BUILTIN_FLAG_NONE,
+    ot_remote_builtin_list_cookies,
     "Show remote repository cookies" },
 #endif
-  { "refs", ot_remote_builtin_refs,
+  { "refs", OSTREE_BUILTIN_FLAG_NONE,
+    ot_remote_builtin_refs,
     "List remote refs" },
-  { "summary", ot_remote_builtin_summary,
+  { "summary", OSTREE_BUILTIN_FLAG_NONE,
+    ot_remote_builtin_summary,
     "Show remote summary" },
-  { NULL, NULL, NULL }
+  { NULL, 0, NULL, NULL }
 };
 
 static GOptionContext *
 remote_option_context_new_with_commands (void)
 {
-  OstreeRemoteCommand *subcommand = remote_subcommands;
+  OstreeCommand *subcommand = remote_subcommands;
   GOptionContext *context = g_option_context_new ("COMMAND");
 
   g_autoptr(GString) summary = g_string_new ("Builtin \"remote\" Commands:");
@@ -80,9 +84,9 @@ remote_option_context_new_with_commands (void)
 }
 
 gboolean
-ostree_builtin_remote (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_remote (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
-  OstreeRemoteCommand *subcommand;
+  OstreeCommand *subcommand;
   const char *subcommand_name = NULL;
   g_autofree char *prgname = NULL;
   gboolean ret = FALSE;
@@ -128,7 +132,7 @@ ostree_builtin_remote (int argc, char **argv, GCancellable *cancellable, GError
 
       /* This will not return for some options (e.g. --version). */
       if (ostree_option_context_parse (context, NULL, &argc, &argv,
-                                       OSTREE_BUILTIN_FLAG_NO_REPO, NULL, cancellable,
+                                       invocation, NULL, cancellable,
                                        error))
         {
           if (subcommand_name == NULL)
@@ -152,7 +156,8 @@ ostree_builtin_remote (int argc, char **argv, GCancellable *cancellable, GError
   prgname = g_strdup_printf ("%s %s", g_get_prgname (), subcommand_name);
   g_set_prgname (prgname);
 
-  if (!subcommand->fn (argc, argv, cancellable, error))
+  OstreeCommandInvocation sub_invocation = { .command = subcommand };
+  if (!subcommand->fn (argc, argv, &sub_invocation, cancellable, error))
     goto out;
 
   ret = TRUE;
index ae1da7cb9b69d193a180eae327cb24c805330d29..f465e0cfbaf27fa9e63b621e05d2456d6e92997c 100644 (file)
@@ -38,6 +38,7 @@ static GOptionEntry options[] = {
 gboolean
 ostree_builtin_reset (int           argc,
                       char        **argv,
+                      OstreeCommandInvocation *invocation,
                       GCancellable *cancellable,
                       GError      **error)
 {
@@ -52,7 +53,7 @@ ostree_builtin_reset (int           argc,
   /* FIXME: Add support for collection–refs. */
   context = g_option_context_new ("REF COMMIT - Reset a REF to a previous COMMIT");
 
-  if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
     goto out;
 
   if (!ostree_ensure_repo_writable (repo, error))
index 060bcdc93dc482f98adbba999a5b5eaba141e57c..cf1da5a627618a30846437f8dba8177cca0eb8a1 100644 (file)
@@ -36,7 +36,7 @@ static GOptionEntry options[] = {
 };
 
 gboolean
-ostree_builtin_rev_parse (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_rev_parse (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeRepo) repo = NULL;
@@ -47,7 +47,7 @@ ostree_builtin_rev_parse (int argc, char **argv, GCancellable *cancellable, GErr
 
   context = g_option_context_new ("REV - Output the target of a rev");
 
-  if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
     goto out;
 
   if (argc < 2)
index c4b586b1eb3648c324ab2d2d5cef91f3e7b3e205..79dfd29e254ebad3f0d81fe7408151c666101453 100644 (file)
@@ -226,12 +226,12 @@ print_if_found (OstreeRepo        *repo,
 }
 
 gboolean
-ostree_builtin_show (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_show (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = g_option_context_new ("OBJECT - Output a metadata object");
 
   g_autoptr(OstreeRepo) repo = NULL;
-  if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
     return FALSE;
 
   if (argc <= 1)
index b2af1d6641606d8387a12cda9d594d3ce4e22694..c9b6b456f393417a4d61b02b9a39c81958fef257 100644 (file)
@@ -39,7 +39,7 @@ static gboolean opt_inline;
 static gboolean opt_disable_bsdiff;
 static gboolean opt_if_not_exists;
 
-#define BUILTINPROTO(name) static gboolean ot_static_delta_builtin_ ## name (int argc, char **argv, GCancellable *cancellable, GError **error)
+#define BUILTINPROTO(name) static gboolean ot_static_delta_builtin_ ## name (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 
 BUILTINPROTO(list);
 BUILTINPROTO(show);
@@ -50,17 +50,22 @@ BUILTINPROTO(apply_offline);
 #undef BUILTINPROTO
 
 static OstreeCommand static_delta_subcommands[] = {
-  { "list", ot_static_delta_builtin_list,
+  { "list", OSTREE_BUILTIN_FLAG_NONE,
+    ot_static_delta_builtin_list,
     "List static delta files" },
-  { "show", ot_static_delta_builtin_show,
+  { "show", OSTREE_BUILTIN_FLAG_NONE,
+    ot_static_delta_builtin_show,
     "Dump information on a delta" },
-  { "delete", ot_static_delta_builtin_delete,
+  { "delete", OSTREE_BUILTIN_FLAG_NONE,
+    ot_static_delta_builtin_delete,
     "Remove a delta" },
-  { "generate", ot_static_delta_builtin_generate,
+  { "generate", OSTREE_BUILTIN_FLAG_NONE,
+    ot_static_delta_builtin_generate,
     "Generate static delta files" },
-  { "apply-offline", ot_static_delta_builtin_apply_offline,
+  { "apply-offline", OSTREE_BUILTIN_FLAG_NONE,
+    ot_static_delta_builtin_apply_offline,
     "Apply static delta file" },
-  { NULL, NULL, NULL }
+  { NULL, 0, NULL, NULL }
 };
 
 /* ATTENTION:
@@ -118,12 +123,12 @@ static_delta_usage (char    **argv,
 }
 
 static gboolean
-ot_static_delta_builtin_list (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_static_delta_builtin_list (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(OstreeRepo) repo = NULL;
   g_autoptr(GOptionContext) context = g_option_context_new ("- list static delta files");
   if (!ostree_option_context_parse (context, list_options, &argc, &argv,
-                                    OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+                                    invocation, &repo, cancellable, error))
     return FALSE;
 
   g_autoptr(GPtrArray) delta_names = NULL;
@@ -142,7 +147,7 @@ ot_static_delta_builtin_list (int argc, char **argv, GCancellable *cancellable,
 }
 
 static gboolean
-ot_static_delta_builtin_show (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_static_delta_builtin_show (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
   g_autoptr(GOptionContext) context = NULL;
@@ -151,7 +156,7 @@ ot_static_delta_builtin_show (int argc, char **argv, GCancellable *cancellable,
 
   context = g_option_context_new ("- Dump information on a delta");
 
-  if (!ostree_option_context_parse (context, list_options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, list_options, &argc, &argv, invocation, &repo, cancellable, error))
     goto out;
 
   if (argc < 3)
@@ -172,7 +177,7 @@ ot_static_delta_builtin_show (int argc, char **argv, GCancellable *cancellable,
 }
 
 static gboolean
-ot_static_delta_builtin_delete (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_static_delta_builtin_delete (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
   g_autoptr(GOptionContext) context = NULL;
@@ -181,7 +186,7 @@ ot_static_delta_builtin_delete (int argc, char **argv, GCancellable *cancellable
 
   context = g_option_context_new ("- Remove a delta");
 
-  if (!ostree_option_context_parse (context, list_options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, list_options, &argc, &argv, invocation, &repo, cancellable, error))
     goto out;
 
   if (argc < 3)
@@ -203,14 +208,14 @@ ot_static_delta_builtin_delete (int argc, char **argv, GCancellable *cancellable
 
 
 static gboolean
-ot_static_delta_builtin_generate (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_static_delta_builtin_generate (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeRepo) repo = NULL;
 
   context = g_option_context_new ("[TO] - Generate static delta files");
-  if (!ostree_option_context_parse (context, generate_options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, generate_options, &argc, &argv, invocation, &repo, cancellable, error))
     goto out;
 
   if (!ostree_ensure_repo_writable (repo, error))
@@ -352,7 +357,7 @@ ot_static_delta_builtin_generate (int argc, char **argv, GCancellable *cancellab
 }
 
 static gboolean
-ot_static_delta_builtin_apply_offline (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_static_delta_builtin_apply_offline (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   gboolean ret = FALSE;
   const char *patharg;
@@ -361,7 +366,7 @@ ot_static_delta_builtin_apply_offline (int argc, char **argv, GCancellable *canc
   g_autoptr(OstreeRepo) repo = NULL;
 
   context = g_option_context_new ("- Apply static delta file");
-  if (!ostree_option_context_parse (context, apply_offline_options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, apply_offline_options, &argc, &argv, invocation, &repo, cancellable, error))
     goto out;
 
   if (!ostree_ensure_repo_writable (repo, error))
@@ -392,7 +397,7 @@ ot_static_delta_builtin_apply_offline (int argc, char **argv, GCancellable *canc
 }
 
 gboolean
-ostree_builtin_static_delta (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_static_delta (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   gboolean want_help = FALSE;
   const char *cmdname = NULL;
@@ -443,5 +448,6 @@ ostree_builtin_static_delta (int argc, char **argv, GCancellable *cancellable, G
   g_autofree char *prgname = g_strdup_printf ("%s %s", g_get_prgname (), cmdname);
   g_set_prgname (prgname);
 
-  return command->fn (argc, argv, cancellable, error);
+  OstreeCommandInvocation sub_invocation = { .command = command };
+  return command->fn (argc, argv, &sub_invocation, cancellable, error);
 }
index 15998efd4dad305871890b22b167e0a89d19002c..a1d0fe566481eb702522cd1f5478a1ee1221bdc8 100644 (file)
@@ -81,7 +81,7 @@ build_additional_metadata (const char * const  *args,
 }
 
 gboolean
-ostree_builtin_summary (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeRepo) repo = NULL;
@@ -89,7 +89,7 @@ ostree_builtin_summary (int argc, char **argv, GCancellable *cancellable, GError
 
   context = g_option_context_new ("Manage summary metadata");
 
-  if (!ostree_option_context_parse (context, options, &argc, &argv, OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+  if (!ostree_option_context_parse (context, options, &argc, &argv, invocation, &repo, cancellable, error))
     return FALSE;
 
   if (opt_update)
index 972cf1ad8313ad776d0bd7088613080c2516b2a9..37487a766a2d23c9a7635b685c995fbffef71d57 100644 (file)
@@ -25,7 +25,7 @@
 #include "otutil.h"
 
 gboolean
-ostree_builtin_trivial_httpd (int argc, char **argv, GCancellable *cancellable, GError **error)
+ostree_builtin_trivial_httpd (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GPtrArray) new_argv = g_ptr_array_new ();
 
index ccb47f6038269ef189a36035e23cfe2b6f44674b..e5864a460b7c224288fd9f03d4f4a1f18ba8451f 100644 (file)
@@ -27,7 +27,7 @@
 
 G_BEGIN_DECLS
 
-#define BUILTINPROTO(name) gboolean ostree_builtin_ ## name (int argc, char **argv, GCancellable *cancellable, GError **error)
+#define BUILTINPROTO(name) gboolean ostree_builtin_ ## name (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 
 BUILTINPROTO(admin);
 BUILTINPROTO(cat);
index d81b802cfa34051a9f783d0a72fa3d9540d7449e..c63cff7e3edc8b6c9c9e498118ee8af38bb1b095 100644 (file)
@@ -171,7 +171,7 @@ ostree_run (int    argc,
         ostree_option_context_new_with_commands (commands);
 
       /* This will not return for some options (e.g. --version). */
-      if (ostree_option_context_parse (context, NULL, &argc, &argv, OSTREE_BUILTIN_FLAG_NO_REPO, NULL, cancellable, &error))
+      if (ostree_option_context_parse (context, NULL, &argc, &argv, NULL, NULL, cancellable, &error))
         {
           if (command_name == NULL)
             {
@@ -193,8 +193,8 @@ ostree_run (int    argc,
   prgname = g_strdup_printf ("%s %s", g_get_prgname (), command_name);
   g_set_prgname (prgname);
 #endif
-
-  if (!command->fn (argc, argv, cancellable, &error))
+  OstreeCommandInvocation invocation = { .command = command };
+  if (!command->fn (argc, argv, &invocation, cancellable, &error))
     goto out;
 
   success = TRUE;
@@ -296,13 +296,14 @@ ostree_option_context_parse (GOptionContext *context,
                              const GOptionEntry *main_entries,
                              int *argc,
                              char ***argv,
-                             OstreeBuiltinFlags flags,
+                             OstreeCommandInvocation *invocation,
                              OstreeRepo **out_repo,
                              GCancellable *cancellable,
                              GError **error)
 {
   g_autoptr(OstreeRepo) repo = NULL;
-
+  /* When invocation is NULL, it usually means an error occurs, do not fetch repo this case */
+  const OstreeBuiltinFlags flags = invocation ? invocation->command->flags : OSTREE_BUILTIN_FLAG_NO_REPO;
   /* Entries are listed in --help output in the order added.  We add the
    * main entries ourselves so that we can add the --repo entry first. */
 
@@ -366,6 +367,7 @@ ostree_admin_option_context_parse (GOptionContext *context,
                                    int *argc,
                                    char ***argv,
                                    OstreeAdminBuiltinFlags flags,
+                                   OstreeCommandInvocation *invocation,
                                    OstreeSysroot **out_sysroot,
                                    GCancellable *cancellable,
                                    GError **error)
@@ -376,7 +378,7 @@ ostree_admin_option_context_parse (GOptionContext *context,
   g_option_context_add_main_entries (context, global_admin_entries, NULL);
 
   if (!ostree_option_context_parse (context, main_entries, argc, argv,
-                                    OSTREE_BUILTIN_FLAG_NO_REPO, NULL, cancellable, error))
+                                    invocation, NULL, cancellable, error))
     return FALSE;
 
   if (!opt_print_current_dir && (flags & OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT))
index d795e53190117e1b6c35852a714143186ed90ee5..26f9f6e1de9a1b87ba42a3690cebf2c4bf0d832a 100644 (file)
@@ -37,12 +37,26 @@ typedef enum {
   OSTREE_ADMIN_BUILTIN_FLAG_NO_SYSROOT = (1 << 2),
 } OstreeAdminBuiltinFlags;
 
+
+typedef struct OstreeCommandInvocation OstreeCommandInvocation;
+
 typedef struct {
   const char *name;
-  gboolean (*fn) (int argc, char **argv, GCancellable *cancellable, GError **error);
+  OstreeBuiltinFlags flags;
+  gboolean (*fn) (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error);
   const char *description;
 } OstreeCommand;
 
+/* This is a similar implementation as
+ * https://github.com/projectatomic/rpm-ostree/commit/12c34bb2491a07079c911ef26401fee939e5573c.
+ *
+ * In the future if we want to add something new we won't need to
+ * touch every prototype
+ */
+struct OstreeCommandInvocation {
+  OstreeCommand *command;
+};
+
 int ostree_run (int argc, char **argv, OstreeCommand *commands, GError **error);
 
 int ostree_usage (OstreeCommand *commands, gboolean is_error);
@@ -58,7 +72,7 @@ gboolean ostree_parse_sysroot_or_repo_option (GOptionContext *context,
 gboolean ostree_option_context_parse (GOptionContext *context,
                                       const GOptionEntry *main_entries,
                                       int *argc, char ***argv,
-                                      OstreeBuiltinFlags flags,
+                                      OstreeCommandInvocation *invocation,
                                       OstreeRepo **out_repo,
                                       GCancellable *cancellable, GError **error);
 
@@ -66,6 +80,7 @@ gboolean ostree_admin_option_context_parse (GOptionContext *context,
                                             const GOptionEntry *main_entries,
                                             int *argc, char ***argv,
                                             OstreeAdminBuiltinFlags flags,
+                                            OstreeCommandInvocation *invocation,
                                             OstreeSysroot **out_sysroot,
                                             GCancellable *cancellable, GError **error);
 
index 764d2fc322dc6380e09c58d9f47d3252debcb8aa..051d0389b9e17e7a734fad4e3536825fc6d4fc5b 100644 (file)
@@ -37,12 +37,12 @@ static GOptionEntry option_entries[] = {
 };
 
 gboolean
-ot_remote_builtin_add_cookie (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_remote_builtin_add_cookie (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = g_option_context_new ("NAME DOMAIN PATH COOKIE_NAME VALUE - Add a cookie to remote");
   g_autoptr(OstreeRepo) repo = NULL;
   if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
-                                    OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+                                    invocation, &repo, cancellable, error))
     return FALSE;
 
   if (argc < 6)
index f099079553beb8d79c97ba6ffecc7656512fd653..080fd5017046a38795a78401d7e728cecf625275 100644 (file)
@@ -57,7 +57,7 @@ static GOptionEntry option_entries[] = {
 };
 
 gboolean
-ot_remote_builtin_add (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_remote_builtin_add (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeSysroot) sysroot = NULL;
@@ -72,7 +72,7 @@ ot_remote_builtin_add (int argc, char **argv, GCancellable *cancellable, GError
   context = g_option_context_new ("NAME [metalink=|mirrorlist=]URL [BRANCH...] - Add a remote repository");
 
   if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
-                                    OSTREE_BUILTIN_FLAG_NO_REPO, NULL, cancellable, error))
+                                    invocation, NULL, cancellable, error))
     goto out;
 
   if (!ostree_parse_sysroot_or_repo_option (context, opt_sysroot, opt_repo,
index 17f356a159771cdebabb589b6d909d0de796b483..726f3ab611e14dac99565961d390143eeb86ddf1 100644 (file)
@@ -38,13 +38,13 @@ static GOptionEntry option_entries[] = {
 };
 
 gboolean
-ot_remote_builtin_delete_cookie (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_remote_builtin_delete_cookie (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(OstreeRepo) repo = NULL;
   g_autoptr(GOptionContext) context = g_option_context_new ("NAME DOMAIN PATH COOKIE_NAME- Remove one cookie from remote");
 
   if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
-                                    OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+                                    invocation, &repo, cancellable, error))
     return FALSE;
 
   if (argc < 5)
index d7ad6bb5e37134c49acd631ae1a08c56bb8c8452..54cba2bfcf2a5781fe6e44ea81983f6c9825fdd5 100644 (file)
@@ -41,13 +41,13 @@ static GOptionEntry option_entries[] = {
 };
 
 gboolean
-ot_remote_builtin_delete (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_remote_builtin_delete (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
 
   g_autoptr(GOptionContext) context = g_option_context_new ("NAME - Delete a remote repository");
 
   if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
-                                    OSTREE_BUILTIN_FLAG_NO_REPO, NULL, cancellable, error))
+                                    invocation, NULL, cancellable, error))
     return FALSE;
 
   g_autoptr(OstreeSysroot) sysroot = NULL;
index 6edcf321f0253a7e3355270fa6d5954f501755df..eca2fee652e4a3b88743e2672e0cc7990954c8c5 100644 (file)
@@ -95,7 +95,7 @@ out:
 }
 
 gboolean
-ot_remote_builtin_gpg_import (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_remote_builtin_gpg_import (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeRepo) repo = NULL;
@@ -108,7 +108,7 @@ ot_remote_builtin_gpg_import (int argc, char **argv, GCancellable *cancellable,
   context = g_option_context_new ("NAME [KEY-ID...] - Import GPG keys");
 
   if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
-                                    OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+                                    invocation, &repo, cancellable, error))
     goto out;
 
   if (argc < 2)
index 99d76346cf67619afa0b1b4ebd791690eca03c4e..7b7ba5d4eeefd9b6ee0f7a49c908874ad7ac5142 100644 (file)
@@ -37,13 +37,13 @@ static GOptionEntry option_entries[] = {
 };
 
 gboolean
-ot_remote_builtin_list_cookies (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_remote_builtin_list_cookies (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(OstreeRepo) repo = NULL;
   g_autoptr(GOptionContext) context = g_option_context_new ("NAME - Show remote repository cookies");
 
   if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
-                                    OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+                                    invocation, &repo, cancellable, error))
     return FALSE;
 
   if (argc < 2)
index fea5e420ba108731ba34b14f747d570d82dbead7..589b97bba982e4b97f028073c351a2b7098ad65d 100644 (file)
@@ -35,7 +35,7 @@ static GOptionEntry option_entries[] = {
 };
 
 gboolean
-ot_remote_builtin_list (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_remote_builtin_list (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeRepo) repo = NULL;
@@ -46,7 +46,7 @@ ot_remote_builtin_list (int argc, char **argv, GCancellable *cancellable, GError
   context = g_option_context_new ("- List remote repository names");
 
   if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
-                                    OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+                                    invocation, &repo, cancellable, error))
     goto out;
 
   remotes = ostree_repo_remote_list (repo, &n_remotes);
index bffc1985f0f15c22d8cc2b61f9f86063394fcc8f..71d5b5d698631bee64c3920dbcef8bc4a7c080fa 100644 (file)
@@ -37,7 +37,7 @@ static GOptionEntry option_entries[] = {
 };
 
 gboolean
-ot_remote_builtin_refs (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_remote_builtin_refs (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeRepo) repo = NULL;
@@ -48,7 +48,7 @@ ot_remote_builtin_refs (int argc, char **argv, GCancellable *cancellable, GError
   context = g_option_context_new ("NAME - List remote refs");
 
   if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
-                                    OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+                                    invocation, &repo, cancellable, error))
     goto out;
 
   if (argc < 2)
index 7ce0572e163db6f2c9de1260402d458f7e9e5437..0f3e56f9d542b7e2a9ec451642232cbf52e23cc6 100644 (file)
@@ -34,7 +34,7 @@ static GOptionEntry option_entries[] = {
 };
 
 gboolean
-ot_remote_builtin_show_url (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_remote_builtin_show_url (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeRepo) repo = NULL;
@@ -45,7 +45,7 @@ ot_remote_builtin_show_url (int argc, char **argv, GCancellable *cancellable, GE
   context = g_option_context_new ("NAME - Show remote repository URL");
 
   if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
-                                    OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+                                    invocation, &repo, cancellable, error))
     goto out;
 
   if (argc < 2)
index 30aedc2dc88ce7d1db1eb3513d2e8a3f0e892a68..8d50158953209ccb137b756b635d5df0826a240e 100644 (file)
@@ -41,7 +41,7 @@ static GOptionEntry option_entries[] = {
 };
 
 gboolean
-ot_remote_builtin_summary (int argc, char **argv, GCancellable *cancellable, GError **error)
+ot_remote_builtin_summary (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(OstreeRepo) repo = NULL;
@@ -55,7 +55,7 @@ ot_remote_builtin_summary (int argc, char **argv, GCancellable *cancellable, GEr
   context = g_option_context_new ("NAME - Show remote summary");
 
   if (!ostree_option_context_parse (context, option_entries, &argc, &argv,
-                                    OSTREE_BUILTIN_FLAG_NONE, &repo, cancellable, error))
+                                    invocation, &repo, cancellable, error))
     goto out;
 
   if (argc < 2)
index c61fcc0791de312aa133e442d75ac915602c8f81..ce788524ab084700ce71272be8819b59c5d1d816 100644 (file)
 
 G_BEGIN_DECLS
 
-gboolean ot_remote_builtin_add (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_remote_builtin_delete (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_remote_builtin_gpg_import (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_remote_builtin_list (int argc, char **argv, GCancellable *cancellable, GError **error);
+#define BUILTINPROTO(name) gboolean ot_remote_builtin_ ## name (int argc, char **argv, \
+                                                                OstreeCommandInvocation *invocation, \
+                                                                GCancellable *cancellable, GError **error)
+
+BUILTINPROTO(add);
+BUILTINPROTO(delete);
+BUILTINPROTO(gpg_import);
+BUILTINPROTO(list);
 #ifdef HAVE_LIBSOUP
-gboolean ot_remote_builtin_add_cookie (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_remote_builtin_list_cookies (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_remote_builtin_delete_cookie (int argc, char **argv, GCancellable *cancellable, GError **error);
+BUILTINPROTO(add_cookie);
+BUILTINPROTO(list_cookies);
+BUILTINPROTO(delete_cookie);
 #endif
-gboolean ot_remote_builtin_show_url (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_remote_builtin_refs (int argc, char **argv, GCancellable *cancellable, GError **error);
-gboolean ot_remote_builtin_summary (int argc, char **argv, GCancellable *cancellable, GError **error);
+BUILTINPROTO(show_url);
+BUILTINPROTO(refs);
+BUILTINPROTO(summary);
+
+#undef BUILTINPROTO
 
 G_END_DECLS