aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-07-24 10:28:53 +0000
committerFuwn <[email protected]>2021-07-24 10:28:53 +0000
commit4aa107b8e6366070f9b67e923252a30661b840bd (patch)
tree8f5ba592c6fadef30d9f7cb364f9bb11683679bd
parentMerge pull request #59 from Whirlsplash/renovate/tokio-1.x (diff)
downloadwhirl-4aa107b8e6366070f9b67e923252a30661b840bd.tar.xz
whirl-4aa107b8e6366070f9b67e923252a30661b840bd.zip
feat(whirl_prompt): whirl mode in fetch builtin
-rw-r--r--crates/whirl_prompt/src/builtins/constants.rs6
-rw-r--r--crates/whirl_prompt/src/builtins/mod.rs41
-rw-r--r--crates/whirl_prompt/src/lib.rs2
3 files changed, 40 insertions, 9 deletions
diff --git a/crates/whirl_prompt/src/builtins/constants.rs b/crates/whirl_prompt/src/builtins/constants.rs
index 1fad9ce..5d1dca0 100644
--- a/crates/whirl_prompt/src/builtins/constants.rs
+++ b/crates/whirl_prompt/src/builtins/constants.rs
@@ -18,3 +18,9 @@ pub const HELPABLES_BUILTIN_CONFIG: [&str; 2] = [
// "refresh - reload the configuration file",
"show - display the current configuration",
];
+pub const HELPABLES_BUILTIN_FETCH: [&str; 4] = [
+ "help - you are here",
+ "show - display the current configuration",
+ "",
+ "-w, --whirl - replace tux with the whirlsplash logo",
+];
diff --git a/crates/whirl_prompt/src/builtins/mod.rs b/crates/whirl_prompt/src/builtins/mod.rs
index 59dbe48..fae1798 100644
--- a/crates/whirl_prompt/src/builtins/mod.rs
+++ b/crates/whirl_prompt/src/builtins/mod.rs
@@ -6,7 +6,7 @@ pub mod structures;
use std::io::Write;
-use constants::{FILES, HELPABLES_BUILTINS, HELPABLES_BUILTIN_CONFIG};
+use constants::{FILES, HELPABLES_BUILTINS, HELPABLES_BUILTIN_CONFIG, HELPABLES_BUILTIN_FETCH};
use sysinfo::SystemExt;
use whirl_config::Config;
@@ -91,18 +91,43 @@ pub fn builtin_config(args: &[String]) -> i32 {
0
}
-pub fn builtin_fetch() -> i32 {
+pub fn builtin_fetch(args: &[String]) -> i32 {
// rfetch: https://github.com/Mangeshrex/rfetch
let mut sys = sysinfo::System::new();
sys.refresh_processes();
+ let mut whirl_image = false;
- println!(" ");
- println!(" .-. os {}", env!("CARGO_PKG_NAME"));
- println!(" oo| ker {}", env!("CARGO_PKG_VERSION"));
- println!(" / '\\ sh /wsh");
- println!(" (\\_;/) up null");
- println!(" ");
+ match args.get(0) {
+ Some(sub) =>
+ match sub.as_str() {
+ "--whirl" | "-w" => whirl_image = true,
+ "help" | "--help" | "-h" => {
+ for help in &HELPABLES_BUILTIN_FETCH {
+ println!("{}", help);
+ }
+ return 0;
+ }
+ _ => println!("invalid arguments provided"),
+ },
+ _ => (),
+ }
+
+ if whirl_image {
+ println!(" -----:::::--- ");
+ println!(" ---:///::/+:- os {}", env!("CARGO_PKG_NAME"));
+ println!(" ---//-//--//- ker {}", env!("CARGO_PKG_VERSION"));
+ println!(" -:/:+-+:://-- sh /wsh");
+ println!(" -//:+-::::--- up null");
+ println!(" --:::-------- ");
+ } else {
+ 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/crates/whirl_prompt/src/lib.rs b/crates/whirl_prompt/src/lib.rs
index 3da4840..ea703c8 100644
--- a/crates/whirl_prompt/src/lib.rs
+++ b/crates/whirl_prompt/src/lib.rs
@@ -106,7 +106,7 @@ impl Prompt {
Ok(BuiltIn::Ls) => builtin_ls(),
Ok(BuiltIn::Cat) => builtin_cat(&c.args),
Ok(BuiltIn::Config) => builtin_config(&c.args),
- Ok(BuiltIn::Fetch) => builtin_fetch(),
+ Ok(BuiltIn::Fetch) => builtin_fetch(&c.args),
Ok(BuiltIn::Clear) => builtin_clear(),
_ => {
println!("wsh: command not found: {}", &c.keyword);