]> git.proxmox.com Git - rustc.git/blob - src/tools/cargo/src/bin/cargo/commands/init.rs
New upstream version 1.75.0+dfsg1
[rustc.git] / src / tools / cargo / src / bin / cargo / commands / init.rs
1 use crate::command_prelude::*;
2
3 use cargo::ops;
4
5 pub fn cli() -> Command {
6 subcommand("init")
7 .about("Create a new cargo package in an existing directory")
8 .arg(
9 Arg::new("path")
10 .value_name("PATH")
11 .action(ArgAction::Set)
12 .default_value("."),
13 )
14 .arg_new_opts()
15 .arg_registry("Registry to use")
16 .arg_quiet()
17 .after_help(color_print::cstr!(
18 "Run `<cyan,bold>cargo help init</>` for more detailed information.\n"
19 ))
20 }
21
22 pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult {
23 let opts = args.new_options(config)?;
24 let project_kind = ops::init(&opts, config)?;
25 config
26 .shell()
27 .status("Created", format!("{} package", project_kind))?;
28 Ok(())
29 }