diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2020-02-23 11:54:33 +0000 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2022-02-26 14:43:48 -0500 |
commit | c6dd82d9f14e9e24a52af637c4a56218ead13eda (patch) | |
tree | 65b9590acf66811be45896845409b2ad6acce5de /src/cli/cmd.c | |
parent | 8526cbd56b0395b9427727e81e6f3c89768337b9 (diff) | |
download | libgit2-c6dd82d9f14e9e24a52af637c4a56218ead13eda.tar.gz |
cli: introduce a help command
Add a framework for commands to be defined, and add our first one,
"help". When `git2_cli help` is run, the `cmd_help` function will be
invoked with the remaining command line arguments. This allows users to
invoke `git2_cli help foo` to get information about the `foo` subcommand.
Diffstat (limited to 'src/cli/cmd.c')
-rw-r--r-- | src/cli/cmd.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/cli/cmd.c b/src/cli/cmd.c new file mode 100644 index 000000000..2a7e71cdb --- /dev/null +++ b/src/cli/cmd.c @@ -0,0 +1,21 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "cli.h" +#include "cmd.h" + +const cli_cmd_spec *cli_cmd_spec_byname(const char *name) +{ + const cli_cmd_spec *cmd; + + for (cmd = cli_cmds; cmd->name; cmd++) { + if (!strcmp(cmd->name, name)) + return cmd; + } + + return NULL; +} |