| 1 |
Git is an example of several common subcommand patterns. |
| 2 |
|
| 3 |
Help: |
| 4 |
```console |
| 5 |
$ git |
| 6 |
? failed |
| 7 |
A fictional versioning CLI |
| 8 |
|
| 9 |
Usage: git[EXE] <COMMAND> |
| 10 |
|
| 11 |
Commands: |
| 12 |
clone Clones repos |
| 13 |
diff Compare two commits |
| 14 |
push pushes things |
| 15 |
add adds things |
| 16 |
stash |
| 17 |
help Print this message or the help of the given subcommand(s) |
| 18 |
|
| 19 |
Options: |
| 20 |
-h, --help Print help |
| 21 |
|
| 22 |
$ git help |
| 23 |
A fictional versioning CLI |
| 24 |
|
| 25 |
Usage: git[EXE] <COMMAND> |
| 26 |
|
| 27 |
Commands: |
| 28 |
clone Clones repos |
| 29 |
diff Compare two commits |
| 30 |
push pushes things |
| 31 |
add adds things |
| 32 |
stash |
| 33 |
help Print this message or the help of the given subcommand(s) |
| 34 |
|
| 35 |
Options: |
| 36 |
-h, --help Print help |
| 37 |
|
| 38 |
$ git help add |
| 39 |
adds things |
| 40 |
|
| 41 |
Usage: git[EXE] add <PATH>... |
| 42 |
|
| 43 |
Arguments: |
| 44 |
<PATH>... Stuff to add |
| 45 |
|
| 46 |
Options: |
| 47 |
-h, --help Print help |
| 48 |
|
| 49 |
``` |
| 50 |
|
| 51 |
A basic argument: |
| 52 |
```console |
| 53 |
$ git add |
| 54 |
? failed |
| 55 |
adds things |
| 56 |
|
| 57 |
Usage: git[EXE] add <PATH>... |
| 58 |
|
| 59 |
Arguments: |
| 60 |
<PATH>... Stuff to add |
| 61 |
|
| 62 |
Options: |
| 63 |
-h, --help Print help |
| 64 |
|
| 65 |
$ git add Cargo.toml Cargo.lock |
| 66 |
Adding ["Cargo.toml", "Cargo.lock"] |
| 67 |
|
| 68 |
``` |
| 69 |
|
| 70 |
Default subcommand: |
| 71 |
```console |
| 72 |
$ git stash -h |
| 73 |
Usage: git[EXE] stash [OPTIONS] |
| 74 |
git[EXE] stash push [OPTIONS] |
| 75 |
git[EXE] stash pop [STASH] |
| 76 |
git[EXE] stash apply [STASH] |
| 77 |
git[EXE] stash help [COMMAND]... |
| 78 |
|
| 79 |
Options: |
| 80 |
-m, --message <MESSAGE> |
| 81 |
-h, --help Print help |
| 82 |
|
| 83 |
git[EXE] stash push: |
| 84 |
-m, --message <MESSAGE> |
| 85 |
-h, --help Print help |
| 86 |
|
| 87 |
git[EXE] stash pop: |
| 88 |
-h, --help Print help |
| 89 |
[STASH] |
| 90 |
|
| 91 |
git[EXE] stash apply: |
| 92 |
-h, --help Print help |
| 93 |
[STASH] |
| 94 |
|
| 95 |
git[EXE] stash help: |
| 96 |
Print this message or the help of the given subcommand(s) |
| 97 |
[COMMAND]... Print help for the subcommand(s) |
| 98 |
|
| 99 |
$ git stash push -h |
| 100 |
Usage: git[EXE] stash push [OPTIONS] |
| 101 |
|
| 102 |
Options: |
| 103 |
-m, --message <MESSAGE> |
| 104 |
-h, --help Print help |
| 105 |
|
| 106 |
$ git stash pop -h |
| 107 |
Usage: git[EXE] stash pop [STASH] |
| 108 |
|
| 109 |
Arguments: |
| 110 |
[STASH] |
| 111 |
|
| 112 |
Options: |
| 113 |
-h, --help Print help |
| 114 |
|
| 115 |
$ git stash -m "Prototype" |
| 116 |
Pushing Some("Prototype") |
| 117 |
|
| 118 |
$ git stash pop |
| 119 |
Popping None |
| 120 |
|
| 121 |
$ git stash push -m "Prototype" |
| 122 |
Pushing Some("Prototype") |
| 123 |
|
| 124 |
$ git stash pop |
| 125 |
Popping None |
| 126 |
|
| 127 |
``` |
| 128 |
|
| 129 |
External subcommands: |
| 130 |
```console |
| 131 |
$ git custom-tool arg1 --foo bar |
| 132 |
Calling out to "custom-tool" with ["arg1", "--foo", "bar"] |
| 133 |
|
| 134 |
``` |
| 135 |
|
| 136 |
Last argument: |
| 137 |
```console |
| 138 |
$ git diff --help |
| 139 |
Compare two commits |
| 140 |
|
| 141 |
Usage: git[EXE] diff [OPTIONS] [COMMIT] [COMMIT] [-- <PATH>] |
| 142 |
|
| 143 |
Arguments: |
| 144 |
[COMMIT] |
| 145 |
[COMMIT] |
| 146 |
[PATH] |
| 147 |
|
| 148 |
Options: |
| 149 |
--color[=<WHEN>] [default: auto] [possible values: always, auto, never] |
| 150 |
-h, --help Print help |
| 151 |
|
| 152 |
$ git diff |
| 153 |
Diffing stage..worktree (color=auto) |
| 154 |
|
| 155 |
$ git diff ./src |
| 156 |
Diffing stage..worktree ./src (color=auto) |
| 157 |
|
| 158 |
$ git diff HEAD ./src |
| 159 |
Diffing HEAD..worktree ./src (color=auto) |
| 160 |
|
| 161 |
$ git diff HEAD~~ -- HEAD |
| 162 |
Diffing HEAD~~..worktree HEAD (color=auto) |
| 163 |
|
| 164 |
$ git diff --color |
| 165 |
Diffing stage..worktree (color=always) |
| 166 |
|
| 167 |
$ git diff --color=never |
| 168 |
Diffing stage..worktree (color=never) |
| 169 |
|
| 170 |
``` |