added version flag
This commit is contained in:
parent
bbbfc924de
commit
de5aa01daf
2 changed files with 17 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "pride"
|
name = "pride"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
22
src/main.rs
22
src/main.rs
|
@ -8,21 +8,30 @@ mod flag;
|
||||||
|
|
||||||
use crate::color::Colors;
|
use crate::color::Colors;
|
||||||
|
|
||||||
|
static VERSION = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut args = Arguments::from_env();
|
let mut args = Arguments::from_env();
|
||||||
|
|
||||||
let help = args.contains(["-h", "--help"]);
|
// handle help flag
|
||||||
if help {
|
if args.contains(["-h", "--help"]) {
|
||||||
help_text();
|
help_text();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let list = args.contains(["-l", "--list"]);
|
// handle list flag
|
||||||
if list {
|
if args.contains(["-l", "--list"]) {
|
||||||
list_text();
|
list_text();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handle version flag
|
||||||
|
if args.contains("--version") {
|
||||||
|
println!("pride v{VERSION}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get small flag
|
||||||
let small = args.contains(["-s", "--small"]);
|
let small = args.contains(["-s", "--small"]);
|
||||||
|
|
||||||
let subcommand = args.subcommand().unwrap();
|
let subcommand = args.subcommand().unwrap();
|
||||||
|
@ -80,7 +89,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn help_text() {
|
fn help_text() {
|
||||||
println!("pride v{}", env!("CARGO_PKG_VERSION"));
|
println!("pride v{VERSION}");
|
||||||
println!("Valerie Wolfe <sleeplessval@gmail.com>");
|
println!("Valerie Wolfe <sleeplessval@gmail.com>");
|
||||||
println!("Show pride flags in the terminal.\n");
|
println!("Show pride flags in the terminal.\n");
|
||||||
|
|
||||||
|
@ -91,6 +100,7 @@ fn help_text() {
|
||||||
|
|
||||||
println!("flags:");
|
println!("flags:");
|
||||||
println!(" -h, --help Shows this help text");
|
println!(" -h, --help Shows this help text");
|
||||||
|
println!(" --version Show version information");
|
||||||
println!(" -l, --list Prints a list of printable flags");
|
println!(" -l, --list Prints a list of printable flags");
|
||||||
println!(" -s, --small Prints a small version without holding");
|
println!(" -s, --small Prints a small version without holding");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue