command : plus lisible
This commit is contained in:
parent
13555cafb3
commit
a05ce8981c
1 changed files with 4 additions and 11 deletions
|
@ -9,9 +9,6 @@ use crate::variables::Variables;
|
|||
|
||||
type BuiltinFunction = fn(&Vec<String>, &mut Variables, &mut ExitCode);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct NoSuchBuiltinError;
|
||||
|
||||
pub trait Command {
|
||||
fn spawn(&mut self, variables: &mut Variables, exit_code: &mut ExitCode);
|
||||
}
|
||||
|
@ -22,7 +19,7 @@ pub struct Builtin {
|
|||
}
|
||||
|
||||
impl Builtin {
|
||||
pub fn new(argv: &Vec<String>) -> Result<Self, NoSuchBuiltinError> {
|
||||
pub fn new(argv: &Vec<String>) -> Result<Self, ()> {
|
||||
let mut args = argv.clone();
|
||||
let program = args.remove(0);
|
||||
|
||||
|
@ -35,13 +32,9 @@ impl Builtin {
|
|||
_ => None,
|
||||
};
|
||||
|
||||
if function.is_some() {
|
||||
Ok(Self {
|
||||
function: function.unwrap(),
|
||||
args,
|
||||
})
|
||||
} else {
|
||||
Err(NoSuchBuiltinError)
|
||||
match function {
|
||||
Some(function) => Ok(Self { function, args }),
|
||||
None => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue