]> git.proxmox.com Git - libgit2.git/blob - src/cli/README.md
New upstream version 1.5.0+ds
[libgit2.git] / src / cli / README.md
1 # cli
2
3 A git-compatible command-line interface that uses libgit2.
4
5 ## Adding commands
6
7 1. Individual commands have a `main`-like top-level entrypoint. For example:
8
9 ```c
10 int cmd_help(int argc, char **argv)
11 ```
12
13 Although this is the same signature as `main`, commands are not built as
14 individual standalone executables, they'll be linked into the main cli.
15 (Though there may be an option for command executables to be built as
16 standalone executables in the future.)
17
18 2. Commands are prototyped in `cmd.h` and added to `main.c`'s list of
19 commands (`cli_cmds[]`). Commands should be specified with their name,
20 entrypoint and a brief description that can be printed in `git help`.
21 This is done because commands are linked into the main cli.
22
23 3. Commands should accept a `--help` option that displays their help
24 information. This will be shown when a user runs `<command> --help` and
25 when a user runs `help <command>`.
26