summaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 20ca9306d4510e8466565aa13a164d0379c4a308 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
use eyre::Result;
use rustyline::DefaultEditor;
use std::path::PathBuf;

fn main() -> Result<()> {
    color_eyre::install()?;

    let mut rl = DefaultEditor::new()?;
    loop {
        let line = rl.readline(">>> ")?;
        println!("{line}");
    }

    Ok(())
}

enum FileSpec {
    Con,
    Path(PathBuf),
}

enum Command {
    Pipe { left: Box<Command>, right: Box<Command> },
    Redirect { command: Box<Command>, target: FileSpec },
    External { program: String, args: Vec<String> },
    Builtin { name: BuiltinCommand },
}

enum BuiltinCommand {
    // File-oriented
    Type { file: FileSpec },
    Copy { from: FileSpec, to: FileSpec },
    Xcopy { from: FileSpec, to: FileSpec, recursive: bool },
    Mkdir { path: PathBuf },
    Remove { path: PathBuf },
    Rmdir { path: PathBuf },
    Rename { from: FileSpec, to: FileSpec },
    Dir { path: PathBuf },
    Tree { path: PathBuf },

    // Shell-oriented
    PromptGet,
    PromptSet { message: String },
    EchoText { message: String },
    EchoOn,
    EchoOff,
    EchoPlain,
    Exit,
    Set { name: String, value: String },
    Chdir { path: PathBuf },
    PathGet,
    PathSet { value: String },
    Ver,

    // Scripting
    Rem { message: String },

    // Utilities
    Date,
    Time,

    // Screen-oriented
    Cls,

    // Dummies
    Verify,

    // For later
    Assign,
    Join,
    Subst,
    Truename,
    Mem,

    // For much later, if ever
    Break,
    Chcp,
    Ctty,
    Vol,
}

impl Command {
    fn parse(_input: &str) -> Result<Command> {
        Err(eyre::eyre!("Not implemented"))
    }
}