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