diff mbox series

[RFC,02/13] walken: add usage to enable -h

Message ID 20190607010811.52944-3-emilyshaffer@google.com (mailing list archive)
State New, archived
Headers show
Series example implementation of revwalk tutorial | expand

Commit Message

Emily Shaffer June 7, 2019, 1:08 a.m. UTC
One requirement of the Git test suite is that all commands support '-h',
which is captured by parse_options(). In order to support this flag, add
a short usage text to walken.c and invoke parse_options().

With this change, we can now add cmd_walken to the builtins set and
expect tests to pass, so we'll do so - cmd_walken is now open for
business.

Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
---
 builtin/walken.c | 12 ++++++++++++
 git.c            |  1 +
 2 files changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/builtin/walken.c b/builtin/walken.c
index bfeaa5188d..5ae7c7d93f 100644
--- a/builtin/walken.c
+++ b/builtin/walken.c
@@ -6,9 +6,21 @@ 
 
 #include <stdio.h>
 #include "builtin.h"
+#include "parse-options.h"
+
+static const char * const walken_usage[] = {
+	N_("git walken"),
+	NULL,
+};
 
 int cmd_walken(int argc, const char **argv, const char *prefix)
 {
+	struct option options[] = {
+		OPT_END()
+	};
+
+	argc = parse_options(argc, argv, prefix, options, walken_usage, 0);
+
 	printf(_("cmd_walken incoming...\n"));
 	return 0;
 }
diff --git a/git.c b/git.c
index 1bf9c94550..209c42836f 100644
--- a/git.c
+++ b/git.c
@@ -600,6 +600,7 @@  static struct cmd_struct commands[] = {
 	{ "verify-pack", cmd_verify_pack },
 	{ "verify-tag", cmd_verify_tag, RUN_SETUP },
 	{ "version", cmd_version },
+	{ "walken", cmd_walken, RUN_SETUP },
 	{ "whatchanged", cmd_whatchanged, RUN_SETUP },
 	{ "worktree", cmd_worktree, RUN_SETUP | NO_PARSEOPT },
 	{ "write-tree", cmd_write_tree, RUN_SETUP },