diff options
| author | Fuwn <[email protected]> | 2021-05-20 03:41:58 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-20 03:41:58 -0700 |
| commit | 1386c836cbe51cbde50698e2dd81a8bef01ed2b6 (patch) | |
| tree | 5dbf42863aa92a462a0dda08bdf8c92e2b0d1fd4 | |
| parent | ci(actions): fix activation paths (diff) | |
| download | whirl-1386c836cbe51cbde50698e2dd81a8bef01ed2b6.tar.xz whirl-1386c836cbe51cbde50698e2dd81a8bef01ed2b6.zip | |
refactor(whirl_prompt): move builtins to their new, respective modules
| -rw-r--r-- | whirl_prompt/src/builtins/mod.rs (renamed from whirl_prompt/src/builtins.rs) | 34 | ||||
| -rw-r--r-- | whirl_prompt/src/builtins/structures.rs | 34 | ||||
| -rw-r--r-- | whirl_prompt/src/lib.rs | 2 |
3 files changed, 38 insertions, 32 deletions
diff --git a/whirl_prompt/src/builtins.rs b/whirl_prompt/src/builtins/mod.rs index b0d02e1..1b94e90 100644 --- a/whirl_prompt/src/builtins.rs +++ b/whirl_prompt/src/builtins/mod.rs @@ -1,43 +1,15 @@ // Copyleft (ɔ) 2021-2021 The Whirlsplash Collective // SPDX-License-Identifier: GPL-3.0-only -use std::{io::Write, str::FromStr}; +pub mod structures; + +use std::io::Write; use sysinfo::SystemExt; use whirl_config::Config; use crate::constants::{FILES, HELPABLES_BUILTINS, HELPABLES_BUILTIN_CONFIG}; -pub enum BuiltIn { - Echo, - History, - Exit, - Null, - Help, - Ls, - Cat, - Config, - Fetch, -} -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), - "null" => Ok(BuiltIn::Null), - "help" => Ok(BuiltIn::Help), - "ls" => Ok(BuiltIn::Ls), - "cat" => Ok(BuiltIn::Cat), - "config" => Ok(BuiltIn::Config), - "fetch" => Ok(BuiltIn::Fetch), - _ => Err(()), - } - } -} - pub fn builtin_echo(args: &[String]) -> i32 { println!("{}", args.join(" ")); 0 diff --git a/whirl_prompt/src/builtins/structures.rs b/whirl_prompt/src/builtins/structures.rs new file mode 100644 index 0000000..4217a38 --- /dev/null +++ b/whirl_prompt/src/builtins/structures.rs @@ -0,0 +1,34 @@ +// Copyleft (ɔ) 2021-2021 The Whirlsplash Collective +// SPDX-License-Identifier: GPL-3.0-only + +use std::str::FromStr; + +pub enum BuiltIn { + Echo, + History, + Exit, + Null, + Help, + Ls, + Cat, + Config, + Fetch, +} +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), + "null" => Ok(BuiltIn::Null), + "help" => Ok(BuiltIn::Help), + "ls" => Ok(BuiltIn::Ls), + "cat" => Ok(BuiltIn::Cat), + "config" => Ok(BuiltIn::Config), + "fetch" => Ok(BuiltIn::Fetch), + _ => Err(()), + } + } +} diff --git a/whirl_prompt/src/lib.rs b/whirl_prompt/src/lib.rs index 2801b3a..3680f04 100644 --- a/whirl_prompt/src/lib.rs +++ b/whirl_prompt/src/lib.rs @@ -28,7 +28,7 @@ use crate::{ builtin_help, builtin_history, builtin_ls, - BuiltIn, + structures::BuiltIn, }, structure::Command, }; |