adding a builtin rm
parent
70e40cb7ae
commit
11a3911f28
@ -1,3 +1,29 @@
|
||||
# clyde
|
||||
|
||||
A command-line shell for Windows.
|
||||
|
||||
## examples
|
||||
|
||||
In all examples, the Clyde prompt is written as follows:
|
||||
|
||||
```
|
||||
▷
|
||||
```
|
||||
|
||||
1. Run a built-in command:
|
||||
|
||||
Built-in commands are invoked by executing them with a bare string
|
||||
|
||||
```
|
||||
c:\dev\clyde ▷ cd src
|
||||
c:\dev\clyde\src ▷
|
||||
```
|
||||
|
||||
2. Run an external command:
|
||||
|
||||
External commands are invoked in the same way:
|
||||
|
||||
```
|
||||
c:\one ▷ cd two
|
||||
c:\one\two ▷
|
||||
```
|
||||
|
@ -0,0 +1,25 @@
|
||||
use crate::{
|
||||
error::ExecError,
|
||||
run::{Call, Context, Value},
|
||||
};
|
||||
use std::fs;
|
||||
|
||||
pub struct Rm;
|
||||
|
||||
impl Call for Rm {
|
||||
fn call(&self, _ctx: &mut Context, args: &[Value]) -> Result<Value, ExecError> {
|
||||
match args.len() {
|
||||
0 => {
|
||||
todo!()
|
||||
}
|
||||
1 => {
|
||||
let path = args[0].try_as_str()?;
|
||||
fs::remove_file(path).map_err(|err| ExecError::Misc(err.to_string()))?;
|
||||
}
|
||||
_ => {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
Ok(Value::None)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue