|
|
@@ -1,5 +1,6 @@
|
|
1
|
1
|
use std::io;
|
|
2
|
2
|
use std::io::prelude::*;
|
|
|
3
|
+use command;
|
|
3
|
4
|
|
|
4
|
5
|
struct Shell<R, W> {
|
|
5
|
6
|
pub reader: R,
|
|
|
@@ -20,9 +21,12 @@ impl Shell<R, W> {
|
|
20
|
21
|
}
|
|
21
|
22
|
/// Initializes the Shell Loop
|
|
22
|
23
|
pub fn start() -> Result<Self, &str> {
|
|
|
24
|
+ shell_loop();
|
|
23
|
25
|
}
|
|
24
|
26
|
/// Waits for user inputs.
|
|
25
|
27
|
fn shell_loop() -> Result {
|
|
|
28
|
+ loop {
|
|
|
29
|
+ }
|
|
26
|
30
|
}
|
|
27
|
31
|
/// Prints the shell prompt.
|
|
28
|
32
|
fn prompt() -> Result<Option, &str> {
|
|
|
@@ -34,11 +38,7 @@ impl Shell<R, W> {
|
|
34
|
38
|
|
|
35
|
39
|
impl BufRead for Shell<R, W> {
|
|
36
|
40
|
fn fill_buf(&mut self) -> Result<&[u8]> {
|
|
37
|
|
- let buf = match stdin.fill_buf() {
|
|
38
|
|
- Ok(res) => res,
|
|
39
|
|
- Err(e) => return Err(e),
|
|
40
|
|
- }
|
|
41
|
|
- buf.unwrap()
|
|
|
41
|
+ stdin.fill_buf()
|
|
42
|
42
|
}
|
|
43
|
43
|
fn consume(&mut self, amt: usize) {
|
|
44
|
44
|
}
|
|
|
@@ -50,10 +50,3 @@ impl Write for Shell<R, W> {
|
|
50
|
50
|
fn flush(&mut self) -> Result<()> {
|
|
51
|
51
|
}
|
|
52
|
52
|
}
|
|
53
|
|
-
|
|
54
|
|
-
|
|
55
|
|
-let mut s = Shell::new();
|
|
56
|
|
- match s.start() {
|
|
57
|
|
- Ok(_) => process::exit(0),
|
|
58
|
|
- Err(_) => process::exit(1),
|
|
59
|
|
- }
|