mkdir creates intermediary directories as required (the default). --create-all/--deep flag removed.

This commit is contained in:
Andrés N. Robalino
2019-08-07 14:38:00 -05:00
parent 50393bdf42
commit ba6d62ea0c
4 changed files with 11 additions and 40 deletions

View File

@@ -154,7 +154,6 @@ pub fn cp(args: CommandArgs) -> Result<OutputStream, ShellError> {
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();

View File

@@ -17,8 +17,7 @@ impl Command for Mkdir {
}
fn config(&self) -> CommandConfig {
let mut named: IndexMap<String, NamedType> = IndexMap::new();
named.insert("create-all".to_string(), NamedType::Switch);
let named: IndexMap<String, NamedType> = IndexMap::new();
CommandConfig {
name: self.name().to_string(),
@@ -39,23 +38,12 @@ pub fn mkdir(args: CommandArgs) -> Result<OutputStream, ShellError> {
_ => {}
}
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()),
}
}