made size flag change non-breaking and adjusted version

This commit is contained in:
Valerie Wolfe 2024-07-05 10:40:24 -04:00
parent 7cecac36ee
commit 0c1c1148c2
4 changed files with 13 additions and 9 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "pride"
version = "1.0.0"
version = "0.4.1"
edition = "2021"
authors = [ "Valerie Wolfe <sleeplessval@gmail.com>" ]
description = "Pride flags in the terminal."

View file

@ -7,7 +7,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl hlv
.Op Fl s Ar size
.Op Fl s Op Ar size
.Op Ar flag
.Sh DESCRIPTION
.Nm
@ -18,8 +18,8 @@ displays pride flags in the terminal using ANSI truecolor sequences.
Shows a brief help text.
.It Fl l , Fl -list
Shows a list of available pride flags.
.It Fl s , Fl -size Ar size
Scales the flag to the given size: 'small' will produce the minimum size; one number sets the width; and two numbers separated by 'x' sets width and height respectively.
.It Fl s , Fl -size Op Ar size
Scales the flag to the given size: no value or 'small' will produce the minimum size; one number sets the width; and two numbers separated by 'x' sets width and height respectively.
.It Fl v , Fl -version
Shows version information.
.It Ar flag

View file

@ -19,7 +19,7 @@ flags:
-h, --help Shows this help text
--version Show version information
-l, --list Prints a list of printable flags
-s, --size <size> Sets the size of the output flag.
-s, --size [size] Sets the size of the output flag.
Use 'pride --list' to see a list of printable flags

View file

@ -50,10 +50,14 @@ impl State {
let is_terminal = stdout().is_terminal();
let size = match args.value_from_str::<[&str;2], String>(FLAG_SIZE).as_deref() {
Ok(value) => Size::from(value),
Err(Error::MissingOption(_)) |
Err(Error::MissingArgument) => if is_terminal { Size::Full } else { Size::Small },
_ => { error::size_missing(); panic!() }
Ok(value) => Size::from(value),
Err(Error::MissingOption(_)) |
Err(Error::MissingArgument) => if is_terminal { Size::Full } else { Size::Small },
Err(Error::OptionWithoutAValue(_)) => Size::Small,
_ => { error::size_missing(); panic!() }
};
State { size, is_terminal }