]>
git.proxmox.com Git - rustc.git/blob - vendor/clap/examples/git.rs
1 // Note: this requires the `cargo` feature
3 use std
::path
::PathBuf
;
5 use clap
::{arg, Command}
;
8 let matches
= Command
::new("git")
9 .about("A fictional versioning CLI")
10 .subcommand_required(true)
11 .arg_required_else_help(true)
12 .allow_external_subcommands(true)
13 .allow_invalid_utf8_for_external_subcommands(true)
16 .about("Clones repos")
17 .arg(arg
!(<REMOTE
> "The remote to clone"))
18 .arg_required_else_help(true),
22 .about("pushes things")
23 .arg(arg
!(<REMOTE
> "The remote to target"))
24 .arg_required_else_help(true),
29 .arg_required_else_help(true)
30 .arg(arg
!(<PATH
> ... "Stuff to add").allow_invalid_utf8(true)),
34 match matches
.subcommand() {
35 Some(("clone", sub_matches
)) => {
38 sub_matches
.value_of("REMOTE").expect("required")
41 Some(("push", sub_matches
)) => {
44 sub_matches
.value_of("REMOTE").expect("required")
47 Some(("add", sub_matches
)) => {
48 let paths
= sub_matches
53 println
!("Adding {:?}", paths
);
55 Some((ext
, sub_matches
)) => {
56 let args
= sub_matches
60 println
!("Calling out to {:?} with {:?}", ext
, args
);
62 _
=> unreachable
!(), // If all subcommands are defined above, anything else is unreachabe!()
65 // Continued program logic goes here...