aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-16 15:44:15 +0000
committerFuwn <[email protected]>2021-05-16 15:44:15 +0000
commit9cf8e0df992084ce62aa60d0df21e1a5e343e901 (patch)
tree1ac5fa1b570a78a7af557c0ca9f525268384638d /src
parentfeat(builtins): usage note on `cat Whirl.toml` (diff)
downloadwhirl-9cf8e0df992084ce62aa60d0df21e1a5e343e901.tar.xz
whirl-9cf8e0df992084ce62aa60d0df21e1a5e343e901.zip
feat(builtins): add a neofetch like utility
Diffstat (limited to 'src')
-rw-r--r--src/prompt/builtins.rs21
-rw-r--r--src/prompt/mod.rs2
2 files changed, 23 insertions, 0 deletions
diff --git a/src/prompt/builtins.rs b/src/prompt/builtins.rs
index 18a5f8e..d58005a 100644
--- a/src/prompt/builtins.rs
+++ b/src/prompt/builtins.rs
@@ -3,6 +3,8 @@
use std::{io::Write, str::FromStr};
+use sysinfo::SystemExt;
+
use crate::config::Config;
const FILES: [&str; 2] = ["README.rst", "Whirl.toml"];
@@ -16,6 +18,7 @@ pub enum BuiltIn {
Ls,
Cat,
Config,
+ Fetch,
}
impl FromStr for BuiltIn {
type Err = ();
@@ -30,6 +33,7 @@ impl FromStr for BuiltIn {
"ls" => Ok(BuiltIn::Ls),
"cat" => Ok(BuiltIn::Cat),
"config" => Ok(BuiltIn::Config),
+ "fetch" => Ok(BuiltIn::Fetch),
_ => Err(()),
}
}
@@ -55,6 +59,7 @@ pub fn builtin_help() -> i32 {
println!("cat - display the contents of a present file");
println!("config - manipulate the configuration");
println!("help - you are here");
+ println!("fetch - a neofetch like utility loosely based on rfetch");
0
}
@@ -119,3 +124,19 @@ pub fn builtin_config(args: &[String]) -> i32 {
}
0
}
+
+pub fn builtin_fetch() -> i32 {
+ // rfetch: https://github.com/Mangeshrex/rfetch
+
+ let mut sys = sysinfo::System::new();
+ sys.refresh_processes();
+
+ println!(" ");
+ println!(" .-. os {}", env!("CARGO_PKG_NAME"));
+ println!(" oo| ker {}", env!("CARGO_PKG_VERSION"));
+ println!(" / '\\ sh /wsh");
+ println!(" (\\_;/) up null");
+ println!(" ");
+
+ 0
+}
diff --git a/src/prompt/mod.rs b/src/prompt/mod.rs
index 3deb4fe..990dd10 100644
--- a/src/prompt/mod.rs
+++ b/src/prompt/mod.rs
@@ -13,6 +13,7 @@ use crate::{
builtin_cat,
builtin_config,
builtin_echo,
+ builtin_fetch,
builtin_help,
builtin_history,
builtin_ls,
@@ -82,6 +83,7 @@ impl Prompt {
Ok(BuiltIn::Ls) => builtin_ls(),
Ok(BuiltIn::Cat) => builtin_cat(&c.args).await,
Ok(BuiltIn::Config) => builtin_config(&c.args),
+ Ok(BuiltIn::Fetch) => builtin_fetch(),
_ => {
println!("wsh: command not found: {}", &c.keyword);
1