summaryrefslogtreecommitdiff
path: root/commands/src/mkdir.rs
blob: 8fe338378f427043ea789dfc8b97a4505ef0f547 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use toolkit::Toolkit;
use toolkit::error::*;
use crate::parser::Command;

pub fn run(tk: &mut Toolkit, command: Command) {
    if command.names.len() == 1 {
        let path = tk.resolve_path(&command.names[0]);

        if !tk.file_exists(&path) {
            tk.mkdir(&path);
        } else {
            display_error(tk, Error::E10);
        }
    } else if command.names.is_empty() {
        display_error(tk, Error::E03);
    } else if command.names.len() > 1 {
        display_error(tk, Error::E08);
    }
}