diff options
Diffstat (limited to 'src/prompt/builtins.rs')
| -rw-r--r-- | src/prompt/builtins.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/prompt/builtins.rs b/src/prompt/builtins.rs new file mode 100644 index 0000000..0ede1d3 --- /dev/null +++ b/src/prompt/builtins.rs @@ -0,0 +1,27 @@ +// Copyleft (ɔ) 2021-2021 The Whirlsplash Collective +// SPDX-License-Identifier: GPL-3.0-only + +use std::str::FromStr; + +pub enum BuiltIn { + Echo, + History, + Exit, +} +impl FromStr for BuiltIn { + type Err = (); + + fn from_str(s: &str) -> Result<Self, Self::Err> { + match s { + "echo" => Ok(BuiltIn::Echo), + "history" => Ok(BuiltIn::History), + "exit" => Ok(BuiltIn::Exit), + _ => Err(()), + } + } +} + +pub fn builtin_echo(args: &[String]) -> i32 { + println!("{}", args.join(" ")); + 0 +} |