diff --git a/man/pride.6 b/man/pride.6 index 8a4135f..0dad758 100644 --- a/man/pride.6 +++ b/man/pride.6 @@ -82,6 +82,13 @@ The rainbow flag designed for 2017 Philadelphia Pride. .It Ic transgender, trans The transgender pride flag designed by Monica Helms in 1999. .El +.Sh ENVIRONMENT +.Bl -tag -width Ds +.It PRIDE_DEFAULT +A string containing the name of a flag to use as the default when no +.Ar flag +argument is provided. +.El .Sh EXIT STATUS .Bl -tag -width Ds .It 1 diff --git a/src/main.rs b/src/main.rs index 1edc848..dbd043d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ //! main method module +use std::env::var; use pico_args::Arguments; @@ -50,7 +51,7 @@ fn main() { let state = State::new(&mut args); - let subcommand = args.subcommand().unwrap(); + let subcommand = if let Ok(Some(subcommand)) = args.subcommand() { Some(subcommand) } else { var("PRIDE_DEFAULT").ok() }; let variant = args.subcommand().unwrap(); // get color vec from matched flag