Debian Codegraph @

debian/rust-vendor/clap/examples/git-derive.md

raw
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 Configurable aliases:
139 Aliases loaded from application configuration can expand into built-in commands
140 and arguments. Built-in commands take precedence over configured aliases.
141
142 ```console
143 $ git-derive last ./src
144 Diffing HEAD~..HEAD ./src (color=auto)
145
146 $ git-derive stage Cargo.toml Cargo.lock
147 Adding ["Cargo.toml", "Cargo.lock"]
148
149 ```
150
151 Last argument:
152 ```console
153 $ git-derive diff --help
154 Compare two commits
155
156 Usage: git-derive[EXE] diff [OPTIONS] [COMMIT] [COMMIT] [-- <PATH>]
157
158 Arguments:
159 [COMMIT]
160 [COMMIT]
161 [PATH]
162
163 Options:
164 --color[=<WHEN>] [default: auto] [possible values: always, auto, never]
165 -h, --help Print help
166
167 $ git-derive diff
168 Diffing stage..worktree (color=auto)
169
170 $ git-derive diff ./src
171 Diffing stage..worktree ./src (color=auto)
172
173 $ git-derive diff HEAD ./src
174 Diffing HEAD..worktree ./src (color=auto)
175
176 $ git-derive diff HEAD~~ -- HEAD
177 Diffing HEAD~~..worktree HEAD (color=auto)
178
179 $ git-derive diff --color
180 Diffing stage..worktree (color=always)
181
182 $ git-derive diff --color=never
183 Diffing stage..worktree (color=never)
184
185 ```