diff --git a/README.md b/README.md index 5cf02bf603..cb3902b81a 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,7 @@ Nu adheres closely to a set of goals that make up its design philosophy. As feat | cd path | Change to a new path | | cp source path | Copy files | | ls (path) | View the contents of the current or given path | -| mkdir path | Make directories, (to create intermediary directories append '--create-all') | +| mkdir path | Make directories, creates intermediary directories as required. | | date (--utc) | Get the current datetime | | ps | View current processes | | sys | View information about the current system | diff --git a/src/commands/cp.rs b/src/commands/cp.rs index 2f7c707fe6..de0f8129c9 100644 --- a/src/commands/cp.rs +++ b/src/commands/cp.rs @@ -154,7 +154,6 @@ pub fn cp(args: CommandArgs) -> Result { sources.walk_decorate(&entry); if entry.is_file() { - let strategy = |(source_file, _depth_level)| { if destination.exists() { let mut new_dst = dunce::canonicalize(destination.clone()).unwrap(); diff --git a/src/commands/mkdir.rs b/src/commands/mkdir.rs index 9bbd285eb0..5dccb28106 100644 --- a/src/commands/mkdir.rs +++ b/src/commands/mkdir.rs @@ -17,8 +17,7 @@ impl Command for Mkdir { } fn config(&self) -> CommandConfig { - let mut named: IndexMap = IndexMap::new(); - named.insert("create-all".to_string(), NamedType::Switch); + let named: IndexMap = IndexMap::new(); CommandConfig { name: self.name().to_string(), @@ -39,23 +38,12 @@ pub fn mkdir(args: CommandArgs) -> Result { _ => {} } - if !args.has("create-all") { - match std::fs::create_dir(full_path) { - Err(_) => Err(ShellError::labeled_error( - "No such file or directory", - "No such file or directory", - args.nth(0).unwrap().span(), - )), - Ok(_) => Ok(OutputStream::empty()), - } - } else { - match std::fs::create_dir_all(full_path) { - Err(reason) => Err(ShellError::labeled_error( - reason.to_string(), - reason.to_string(), - args.nth(0).unwrap().span(), - )), - Ok(_) => Ok(OutputStream::empty()), - } + match std::fs::create_dir_all(full_path) { + Err(reason) => Err(ShellError::labeled_error( + reason.to_string(), + reason.to_string(), + args.nth(0).unwrap().span(), + )), + Ok(_) => Ok(OutputStream::empty()), } } diff --git a/tests/command_mkdir_tests.rs b/tests/command_mkdir_tests.rs index 9d78365535..9cbb10755c 100644 --- a/tests/command_mkdir_tests.rs +++ b/tests/command_mkdir_tests.rs @@ -19,31 +19,15 @@ fn creates_directory() { } #[test] -fn error_if_intermediary_directory_doesnt_exist() { +fn creates_intermediary_directories() { let sandbox = Playground::setup_for("mkdir_test_2").test_dir_name(); let full_path = format!("{}/{}", Playground::root(), sandbox); - nu_error!( - output, - cwd(&full_path), - "mkdir some_folder/another/deeper_one" - ); - - assert!(output.contains("some_folder/another/deeper_one")); - assert!(output.contains("No such file or directory")); -} - -#[test] -fn creates_intermediary_directories_with_p_flag() { - let sandbox = Playground::setup_for("mkdir_test_3").test_dir_name(); - - let full_path = format!("{}/{}", Playground::root(), sandbox); - nu!( _output, cwd(&full_path), - "mkdir some_folder/another/deeper_one --create-all" + "mkdir some_folder/another/deeper_one" ); let mut expected = PathBuf::from(full_path);