mirror of
https://github.com/Atsukoro1/ponyfetch.git
synced 2024-11-27 06:17:59 +01:00
feat: 🎸 List all available ponies
This commit is contained in:
parent
b847d16307
commit
7a5b8b5517
2 changed files with 24 additions and 0 deletions
|
@ -4,6 +4,7 @@ use crate::helpers::colors::COLORS;
|
|||
pub struct Arguments {
|
||||
pub help: bool,
|
||||
pub color: String,
|
||||
pub list: bool,
|
||||
pub pony: String
|
||||
}
|
||||
|
||||
|
@ -38,12 +39,24 @@ impl Arguments {
|
|||
println!("
|
||||
-h, --help Display this help and exit
|
||||
-c, --color Set the color of the pony
|
||||
-l, --list List all available ponies
|
||||
-p, --pony Set the pony to display
|
||||
");
|
||||
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
||||
fn print_ponies() {
|
||||
let ponies = crate::helpers::paths::get_ponies();
|
||||
|
||||
println!("Available ponies:");
|
||||
for pony in ponies.iter() {
|
||||
println!(" {}", pony);
|
||||
}
|
||||
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
||||
fn print_err(err: &str) {
|
||||
println!("Error: {}", err);
|
||||
println!("Usage: ponyfetch [OPTION]...");
|
||||
|
@ -64,6 +77,7 @@ impl Arguments {
|
|||
pub fn parse() -> Arguments {
|
||||
let mut args = Arguments {
|
||||
help: false,
|
||||
list: false,
|
||||
color: String::from(""),
|
||||
pony: String::from("")
|
||||
};
|
||||
|
@ -85,6 +99,8 @@ impl Arguments {
|
|||
Self::get_args(arg)
|
||||
);
|
||||
},
|
||||
|
||||
arg if arg == "--list" || arg == "-l" => args.list = true,
|
||||
_ => ()
|
||||
}
|
||||
});
|
||||
|
@ -101,6 +117,10 @@ impl Arguments {
|
|||
Self::print_help();
|
||||
}
|
||||
|
||||
if args.list {
|
||||
Self::print_ponies();
|
||||
}
|
||||
|
||||
args
|
||||
}
|
||||
}
|
|
@ -4,14 +4,18 @@ pub fn get_ponies() -> Vec<&'static str> {
|
|||
"applejack_large",
|
||||
"celestia_large",
|
||||
"fluttershy_large",
|
||||
#[cfg(target_os = "linux")]
|
||||
"fluttershy",
|
||||
"luna_large",
|
||||
"mcintosh_large",
|
||||
"pinkiepie_large",
|
||||
"rainbowdash_large",
|
||||
#[cfg(target_os = "linux")]
|
||||
"rainbowdash",
|
||||
#[cfg(target_os = "linux")]
|
||||
"rarity",
|
||||
"twilight_large",
|
||||
#[cfg(target_os = "linux")]
|
||||
"twilight",
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue