]> git.proxmox.com Git - rustc.git/blob - vendor/clap/examples/git-derive.md
New upstream version 1.68.2+dfsg1
[rustc.git] / vendor / clap / examples / git-derive.md
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 <COMMAND>
77
78 Commands:
79 push
80 pop
81 apply
82 help Print this message or the help of the given subcommand(s)
83
84 Options:
85 -m, --message <MESSAGE>
86 -h, --help Print help
87
88 $ git-derive stash push -h
89 Usage: git-derive[EXE] stash push [OPTIONS]
90
91 Options:
92 -m, --message <MESSAGE>
93 -h, --help Print help
94
95 $ git-derive stash pop -h
96 Usage: git-derive[EXE] stash pop [STASH]
97
98 Arguments:
99 [STASH]
100
101 Options:
102 -h, --help Print help
103
104 $ git-derive stash -m "Prototype"
105 Pushing StashPush { message: Some("Prototype") }
106
107 $ git-derive stash pop
108 Popping None
109
110 $ git-derive stash push -m "Prototype"
111 Pushing StashPush { message: Some("Prototype") }
112
113 $ git-derive stash pop
114 Popping None
115
116 ```
117
118 External subcommands:
119 ```console
120 $ git-derive custom-tool arg1 --foo bar
121 Calling out to "custom-tool" with ["arg1", "--foo", "bar"]
122
123 ```
124
125 Last argument:
126 ```console
127 $ git-derive diff --help
128 Compare two commits
129
130 Usage: git-derive[EXE] diff [OPTIONS] [COMMIT] [COMMIT] [-- <PATH>]
131
132 Arguments:
133 [COMMIT]
134 [COMMIT]
135 [PATH]
136
137 Options:
138 --color[=<WHEN>] [default: auto] [possible values: always, auto, never]
139 -h, --help Print help
140
141 $ git-derive diff
142 Diffing stage..worktree (color=auto)
143
144 $ git-derive diff ./src
145 Diffing stage..worktree ./src (color=auto)
146
147 $ git-derive diff HEAD ./src
148 Diffing HEAD..worktree ./src (color=auto)
149
150 $ git-derive diff HEAD~~ -- HEAD
151 Diffing HEAD~~..worktree HEAD (color=auto)
152
153 $ git-derive diff --color
154 Diffing stage..worktree (color=always)
155
156 $ git-derive diff --color=never
157 Diffing stage..worktree (color=never)
158
159 ```