blob: 6b12e5ba53391c55e6c725c3d786aee13e455598 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
use toolkit::Toolkit;
use toolkit::error::*;
use crate::parser::Command;
pub fn run(mut tk: &mut Toolkit, command: Command) {
if command.names.len() == 1 {
let path = tk.resolve_path(&command.names[0]);
if tk.file_exists(&path) {
if tk.is_dir(&path) {
tk.chdir(&path);
} else {
display_error(&mut tk, Error::E09);
}
return;
} else {
display_error(&mut tk, Error::E04);
}
} else if command.names.len() == 0 {
display_error(&mut tk, Error::E03);
} else if command.names.len() > 1 {
display_error(&mut tk, Error::E08);
}
}
|