summaryrefslogtreecommitdiff
path: root/src/ostree/main.c
diff options
context:
space:
mode:
authorRuixin Bao <peter.bao@mail.utoronto.ca>2017-10-17 17:25:04 +0000
committerAtomic Bot <atomic-devel@projectatomic.io>2017-10-20 12:59:33 +0000
commit298c151fd8f78e6c3f6f199cd32981ae3d311828 (patch)
tree596d088bc885b26d540d5bdb91ba89aa7b20c5b4 /src/ostree/main.c
parent3c360a720ff1a8bf695365a79b3ac7975ffd25e8 (diff)
downloadostree-298c151fd8f78e6c3f6f199cd32981ae3d311828.tar.gz
ostree: move flags into command struct, pass down through builtins
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
Diffstat (limited to 'src/ostree/main.c')
-rw-r--r--src/ostree/main.c83
1 files changed, 57 insertions, 26 deletions
diff --git a/src/ostree/main.c b/src/ostree/main.c
index ef8f1f8a..4ae261d6 100644
--- a/src/ostree/main.c
+++ b/src/ostree/main.c
@@ -32,62 +32,93 @@
#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 }