})
}
-fn check_name(name: &str, name_help: &str, has_bin: bool, shell: &mut Shell) -> CargoResult<()> {
+fn check_name(
+ name: &str,
+ show_name_help: bool,
+ has_bin: bool,
+ shell: &mut Shell,
+) -> CargoResult<()> {
+ // If --name is already used to override, no point in suggesting it
+ // again as a fix.
+ let name_help = if show_name_help {
+ "\nuse --name to override crate name"
+ } else {
+ ""
+ };
restricted_names::validate_package_name(name, "crate name", name_help)?;
if restricted_names::is_keyword(name) {
}
let name = get_name(path, opts)?;
- check_name(name, "", opts.kind.is_bin(), &mut config.shell())?;
+ check_name(
+ name,
+ opts.name.is_none(),
+ opts.kind.is_bin(),
+ &mut config.shell(),
+ )?;
let mkopts = MkOptions {
version_control: opts.version_control,
// user may mean "initialize for library, but also add binary target"
}
let has_bin = src_paths_types.iter().any(|x| x.bin);
- // If --name is already used to override, no point in suggesting it
- // again as a fix.
- let name_help = match opts.name {
- Some(_) => "",
- None => "\nuse --name to override crate name",
- };
- check_name(name, name_help, has_bin, &mut config.shell())?;
+ check_name(name, opts.name.is_none(), has_bin, &mut config.shell())?;
let mut version_control = opts.version_control;