feat: 🎸 List all available ponies

This commit is contained in:
Atsukoro1 2022-12-05 23:09:22 +01:00
parent b847d16307
commit 7a5b8b5517
2 changed files with 24 additions and 0 deletions

View file

@ -4,6 +4,7 @@ use crate::helpers::colors::COLORS;
pub struct Arguments { pub struct Arguments {
pub help: bool, pub help: bool,
pub color: String, pub color: String,
pub list: bool,
pub pony: String pub pony: String
} }
@ -38,12 +39,24 @@ impl Arguments {
println!(" println!("
-h, --help Display this help and exit -h, --help Display this help and exit
-c, --color Set the color of the pony -c, --color Set the color of the pony
-l, --list List all available ponies
-p, --pony Set the pony to display -p, --pony Set the pony to display
"); ");
std::process::exit(0); 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) { fn print_err(err: &str) {
println!("Error: {}", err); println!("Error: {}", err);
println!("Usage: ponyfetch [OPTION]..."); println!("Usage: ponyfetch [OPTION]...");
@ -64,6 +77,7 @@ impl Arguments {
pub fn parse() -> Arguments { pub fn parse() -> Arguments {
let mut args = Arguments { let mut args = Arguments {
help: false, help: false,
list: false,
color: String::from(""), color: String::from(""),
pony: String::from("") pony: String::from("")
}; };
@ -85,6 +99,8 @@ impl Arguments {
Self::get_args(arg) Self::get_args(arg)
); );
}, },
arg if arg == "--list" || arg == "-l" => args.list = true,
_ => () _ => ()
} }
}); });
@ -101,6 +117,10 @@ impl Arguments {
Self::print_help(); Self::print_help();
} }
if args.list {
Self::print_ponies();
}
args args
} }
} }

View file

@ -4,14 +4,18 @@ pub fn get_ponies() -> Vec<&'static str> {
"applejack_large", "applejack_large",
"celestia_large", "celestia_large",
"fluttershy_large", "fluttershy_large",
#[cfg(target_os = "linux")]
"fluttershy", "fluttershy",
"luna_large", "luna_large",
"mcintosh_large", "mcintosh_large",
"pinkiepie_large", "pinkiepie_large",
"rainbowdash_large", "rainbowdash_large",
#[cfg(target_os = "linux")]
"rainbowdash", "rainbowdash",
#[cfg(target_os = "linux")]
"rarity", "rarity",
"twilight_large", "twilight_large",
#[cfg(target_os = "linux")]
"twilight", "twilight",
] ]
} }