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