blob: 75902662fe22ffb5299ec53749910586b662dd02 (
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
26
27
28
29
30
|
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_file(&path) {
match tk.read_file(&path) {
None => {
display_error(&mut tk, Error::E13);
}
Some(str) => {
tk.println(&str.replace("\n", "\r\n").replace("\r\r\n", "\r\n"));
}
}
} else {
display_error(&mut tk, Error::E12);
}
} 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);
}
}
|