forked from rust-lang/cargo
/
new.rs
30 lines (26 loc) · 825 Bytes
/
new.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use crate::command_prelude::*;
use cargo::ops;
pub fn cli() -> App {
subcommand("new")
.about("Create a new cargo package at <path>")
.arg_quiet()
.arg(Arg::with_name("path").required(true))
.arg(opt("registry", "Registry to use").value_name("REGISTRY"))
.arg_new_opts()
.after_help("Run `cargo help new` for more detailed information.\n")
}
pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
let opts = args.new_options(config)?;
ops::new(&opts, config)?;
let path = args.value_of("path").unwrap();
let package_name = if let Some(name) = args.value_of("name") {
name
} else {
path
};
config.shell().status(
"Created",
format!("{} `{}` package", opts.kind, package_name),
)?;
Ok(())
}