diff options
| author | Fuwn <[email protected]> | 2021-07-24 10:28:53 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-07-24 10:28:53 +0000 |
| commit | 88833b1c66aa9b0c3c1f87b606f7a6175fe8f05e (patch) | |
| tree | 6d2d88c7a4ce81ddfda7cd03c002a28e0d7b22cb /crates/whirl_prompt/src/builtins | |
| parent | Merge pull request #59 from Whirlsplash/renovate/tokio-1.x (diff) | |
| download | whirl-88833b1c66aa9b0c3c1f87b606f7a6175fe8f05e.tar.xz whirl-88833b1c66aa9b0c3c1f87b606f7a6175fe8f05e.zip | |
feat(whirl_prompt): whirl mode in fetch builtin
Diffstat (limited to 'crates/whirl_prompt/src/builtins')
| -rw-r--r-- | crates/whirl_prompt/src/builtins/constants.rs | 6 | ||||
| -rw-r--r-- | crates/whirl_prompt/src/builtins/mod.rs | 41 |
2 files changed, 39 insertions, 8 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 } |