Compare commits

...

13 commits
v0.4.1 ... main

8 changed files with 164 additions and 125 deletions

View file

@ -1,11 +1,11 @@
[package] [package]
name = "pride" name = "pride"
version = "0.4.1" version = "0.4.3"
edition = "2021" edition = "2021"
authors = [ "Valerie Wolfe <sleeplessval@gmail.com>" ] authors = [ "Valerie Wolfe <sleeplessval@gmail.com>" ]
description = "Pride flags in the terminal." description = "Pride flags in the terminal."
homepage = "https://git.vwolfe.io/valerie/pride" homepage = "https://git.sleeplessval.io/valerie/pride"
repository = "https://git.vwolfe.io/valerie/pride" repository = "https://git.sleeplessval.io/valerie/pride"
license = "MIT" license = "MIT"
categories = [ "command-line-utilities" ] categories = [ "command-line-utilities" ]
keywords = [ "lgbt", "pride", "cli" ] keywords = [ "lgbt", "pride", "cli" ]
@ -19,8 +19,9 @@ name = "pride"
path = "src/main.rs" path = "src/main.rs"
[dependencies] [dependencies]
oorandom = '11.1.4'
pico-args = "0.5.0" pico-args = "0.5.0"
termion = "3.0.0" termion = "4.0.3"
[profile.release] [profile.release]
opt-level = 's' opt-level = 's'

View file

@ -3,7 +3,7 @@
A Rust utility to display pride flags in the terminal. A Rust utility to display pride flags in the terminal.
A list of currently implemented flags is available on the [project wiki](https://git.vwolfe.io/valerie/pride/wiki/Flags). A list of currently implemented flags is available on the [project wiki](https://git.sleeplessval.io/valerie/pride/wiki/Flags).
## Dependencies ## Dependencies
@ -16,7 +16,7 @@ slant symbols, and therefore require use of a Powerline font, such as [Fira Code
<details> <details>
<summary>Release Binary</summary> <summary>Release Binary</summary>
Copy the compiled binary from the <a href="https://git.vwolfe.io/valerie/pride/releases/">releases page</a> Copy the compiled binary from the <a href="https://git.sleeplessval.io/valerie/pride/releases/">releases page</a>
to a directory in <code>$PATH</code>, such as <code>/usr/bin/</code>. to a directory in <code>$PATH</code>, such as <code>/usr/bin/</code>.
</details> </details>

View file

@ -55,7 +55,7 @@ The 5-stripe lesbian pride flag designed by Emily Gwen in 2018.
.Pp .Pp
VARIANTS VARIANTS
.Bl -tag -width Ds -compact .Bl -tag -width Ds -compact
.It Ic 7-color .It Ic 7, 7-color, 7-stripe
The 7-stripe lesbian pride flag designed by Emily Gwen in 2018. The 7-stripe lesbian pride flag designed by Emily Gwen in 2018.
.El .El
.It Ic multisexual, m-spec, mspec .It Ic multisexual, m-spec, mspec
@ -82,6 +82,17 @@ The rainbow flag designed for 2017 Philadelphia Pride.
.It Ic transgender, trans .It Ic transgender, trans
The transgender pride flag designed by Monica Helms in 1999. The transgender pride flag designed by Monica Helms in 1999.
.El .El
.Sh ENVIRONMENT
.Bl -tag -width Ds
.It PRIDE_DEFAULT
A string containing the name of one or more flags to use as the default when no
.Ar flag
argument is provided. If the string contains a semicolon-separated list of flags, a random one will be selected from the list. If a space is found in the chosen substring, it will be used to provide the
.Ar flag
and
.Ar variant
arguments.
.El
.Sh EXIT STATUS .Sh EXIT STATUS
.Bl -tag -width Ds .Bl -tag -width Ds
.It 1 .It 1

212
sbom.xml
View file

@ -1,13 +1,13 @@
{ {
"SPDXID": "SPDXRef-DOCUMENT", "SPDXID": "SPDXRef-DOCUMENT",
"creationInfo": { "creationInfo": {
"created": "2024-07-05T20:16:51.403Z", "created": "2024-12-13T16:02:17.260Z",
"creators": [ "creators": [
"Tool: cargo-sbom-v0.8.4" "Tool: cargo-sbom-v0.8.4"
] ]
}, },
"dataLicense": "CC0-1.0", "dataLicense": "CC0-1.0",
"documentNamespace": "https://spdx.org/spdxdocs/pride-6150510e-b518-43f0-aa53-3e2795909cc2", "documentNamespace": "https://spdx.org/spdxdocs/pride-93ad73c9-b337-4ad0-bd63-92e9b7d1a2d8",
"files": [ "files": [
{ {
"SPDXID": "SPDXRef-File-pride", "SPDXID": "SPDXRef-File-pride",
@ -21,70 +21,62 @@
"name": "pride", "name": "pride",
"packages": [ "packages": [
{ {
"SPDXID": "SPDXRef-Package-redox_syscall-0.4.1", "SPDXID": "SPDXRef-Package-oorandom-11.1.4",
"description": "A tiny, robust PRNG implementation.",
"downloadLocation": "registry+https://github.com/rust-lang/crates.io-index",
"externalRefs": [
{
"referenceCategory": "PACKAGE-MANAGER",
"referenceLocator": "pkg:cargo/oorandom@11.1.4",
"referenceType": "purl"
}
],
"licenseConcluded": "MIT",
"licenseDeclared": "MIT",
"name": "oorandom",
"versionInfo": "11.1.4"
},
{
"SPDXID": "SPDXRef-Package-redox_syscall-0.5.7",
"description": "A Rust library to access raw Redox system calls", "description": "A Rust library to access raw Redox system calls",
"downloadLocation": "registry+https://github.com/rust-lang/crates.io-index", "downloadLocation": "registry+https://github.com/rust-lang/crates.io-index",
"externalRefs": [ "externalRefs": [
{ {
"referenceCategory": "PACKAGE-MANAGER", "referenceCategory": "PACKAGE-MANAGER",
"referenceLocator": "pkg:cargo/redox_syscall@0.4.1", "referenceLocator": "pkg:cargo/redox_syscall@0.5.7",
"referenceType": "purl" "referenceType": "purl"
} }
], ],
"licenseConcluded": "MIT", "licenseConcluded": "MIT",
"licenseDeclared": "MIT", "licenseDeclared": "MIT",
"name": "redox_syscall", "name": "redox_syscall",
"versionInfo": "0.4.1" "versionInfo": "0.5.7"
}, },
{ {
"SPDXID": "SPDXRef-Package-libredox-0.0.2", "SPDXID": "SPDXRef-Package-pride-0.4.3",
"description": "Redox stable ABI", "description": "Pride flags in the terminal.",
"downloadLocation": "NONE",
"homepage": "https://git.sleeplessval.io/valerie/pride",
"licenseConcluded": "MIT",
"licenseDeclared": "MIT",
"name": "pride",
"versionInfo": "0.4.3"
},
{
"SPDXID": "SPDXRef-Package-termion-4.0.3",
"description": "A bindless library for manipulating terminals.",
"downloadLocation": "registry+https://github.com/rust-lang/crates.io-index", "downloadLocation": "registry+https://github.com/rust-lang/crates.io-index",
"externalRefs": [ "externalRefs": [
{ {
"referenceCategory": "PACKAGE-MANAGER", "referenceCategory": "PACKAGE-MANAGER",
"referenceLocator": "pkg:cargo/libredox@0.0.2", "referenceLocator": "pkg:cargo/termion@4.0.3",
"referenceType": "purl" "referenceType": "purl"
} }
], ],
"licenseConcluded": "MIT", "licenseConcluded": "MIT",
"licenseDeclared": "MIT", "licenseDeclared": "MIT",
"name": "libredox", "name": "termion",
"versionInfo": "0.0.2" "versionInfo": "4.0.3"
},
{
"SPDXID": "SPDXRef-Package-libc-0.2.155",
"description": "Raw FFI bindings to platform libraries like libc.\n",
"downloadLocation": "registry+https://github.com/rust-lang/crates.io-index",
"externalRefs": [
{
"referenceCategory": "PACKAGE-MANAGER",
"referenceLocator": "pkg:cargo/libc@0.2.155",
"referenceType": "purl"
}
],
"homepage": "https://github.com/rust-lang/libc",
"licenseConcluded": "MIT OR Apache-2.0",
"licenseDeclared": "MIT OR Apache-2.0",
"name": "libc",
"versionInfo": "0.2.155"
},
{
"SPDXID": "SPDXRef-Package-bitflags-1.3.2",
"description": "A macro to generate structures which behave like bitflags.\n",
"downloadLocation": "registry+https://github.com/rust-lang/crates.io-index",
"externalRefs": [
{
"referenceCategory": "PACKAGE-MANAGER",
"referenceLocator": "pkg:cargo/bitflags@1.3.2",
"referenceType": "purl"
}
],
"homepage": "https://github.com/bitflags/bitflags",
"licenseConcluded": "MIT OR Apache-2.0",
"licenseDeclared": "MIT/Apache-2.0",
"name": "bitflags",
"versionInfo": "1.3.2"
}, },
{ {
"SPDXID": "SPDXRef-Package-redox_termios-0.1.3", "SPDXID": "SPDXRef-Package-redox_termios-0.1.3",
@ -103,45 +95,30 @@
"versionInfo": "0.1.3" "versionInfo": "0.1.3"
}, },
{ {
"SPDXID": "SPDXRef-Package-numtoa-0.1.0", "SPDXID": "SPDXRef-Package-libc-0.2.167",
"description": "Convert numbers into stack-allocated byte arrays", "description": "Raw FFI bindings to platform libraries like libc.\n",
"downloadLocation": "registry+https://github.com/rust-lang/crates.io-index", "downloadLocation": "registry+https://github.com/rust-lang/crates.io-index",
"externalRefs": [ "externalRefs": [
{ {
"referenceCategory": "PACKAGE-MANAGER", "referenceCategory": "PACKAGE-MANAGER",
"referenceLocator": "pkg:cargo/numtoa@0.1.0", "referenceLocator": "pkg:cargo/libc@0.2.167",
"referenceType": "purl" "referenceType": "purl"
} }
], ],
"homepage": "https://github.com/rust-lang/libc",
"licenseConcluded": "MIT OR Apache-2.0", "licenseConcluded": "MIT OR Apache-2.0",
"licenseDeclared": "MIT OR Apache-2.0", "licenseDeclared": "MIT OR Apache-2.0",
"name": "numtoa", "name": "libc",
"versionInfo": "0.1.0" "versionInfo": "0.2.167"
}, },
{ {
"SPDXID": "SPDXRef-Package-termion-3.0.0", "SPDXID": "SPDXRef-Package-bitflags-2.6.0",
"description": "A bindless library for manipulating terminals.",
"downloadLocation": "registry+https://github.com/rust-lang/crates.io-index",
"externalRefs": [
{
"referenceCategory": "PACKAGE-MANAGER",
"referenceLocator": "pkg:cargo/termion@3.0.0",
"referenceType": "purl"
}
],
"licenseConcluded": "MIT",
"licenseDeclared": "MIT",
"name": "termion",
"versionInfo": "3.0.0"
},
{
"SPDXID": "SPDXRef-Package-bitflags-2.5.0",
"description": "A macro to generate structures which behave like bitflags.\n", "description": "A macro to generate structures which behave like bitflags.\n",
"downloadLocation": "registry+https://github.com/rust-lang/crates.io-index", "downloadLocation": "registry+https://github.com/rust-lang/crates.io-index",
"externalRefs": [ "externalRefs": [
{ {
"referenceCategory": "PACKAGE-MANAGER", "referenceCategory": "PACKAGE-MANAGER",
"referenceLocator": "pkg:cargo/bitflags@2.5.0", "referenceLocator": "pkg:cargo/bitflags@2.6.0",
"referenceType": "purl" "referenceType": "purl"
} }
], ],
@ -149,17 +126,39 @@
"licenseConcluded": "MIT OR Apache-2.0", "licenseConcluded": "MIT OR Apache-2.0",
"licenseDeclared": "MIT OR Apache-2.0", "licenseDeclared": "MIT OR Apache-2.0",
"name": "bitflags", "name": "bitflags",
"versionInfo": "2.5.0" "versionInfo": "2.6.0"
}, },
{ {
"SPDXID": "SPDXRef-Package-pride-0.4.1", "SPDXID": "SPDXRef-Package-libredox-0.1.3",
"description": "Pride flags in the terminal.", "description": "Redox stable ABI",
"downloadLocation": "NONE", "downloadLocation": "registry+https://github.com/rust-lang/crates.io-index",
"homepage": "https://git.vwolfe.io/valerie/pride", "externalRefs": [
{
"referenceCategory": "PACKAGE-MANAGER",
"referenceLocator": "pkg:cargo/libredox@0.1.3",
"referenceType": "purl"
}
],
"licenseConcluded": "MIT", "licenseConcluded": "MIT",
"licenseDeclared": "MIT", "licenseDeclared": "MIT",
"name": "pride", "name": "libredox",
"versionInfo": "0.4.1" "versionInfo": "0.1.3"
},
{
"SPDXID": "SPDXRef-Package-numtoa-0.2.4",
"description": "Convert numbers into stack-allocated byte arrays",
"downloadLocation": "registry+https://github.com/rust-lang/crates.io-index",
"externalRefs": [
{
"referenceCategory": "PACKAGE-MANAGER",
"referenceLocator": "pkg:cargo/numtoa@0.2.4",
"referenceType": "purl"
}
],
"licenseConcluded": "MIT OR Apache-2.0",
"licenseDeclared": "MIT OR Apache-2.0",
"name": "numtoa",
"versionInfo": "0.2.4"
}, },
{ {
"SPDXID": "SPDXRef-Package-pico-args-0.5.0", "SPDXID": "SPDXRef-Package-pico-args-0.5.0",
@ -180,59 +179,64 @@
], ],
"relationships": [ "relationships": [
{ {
"relatedSpdxElement": "SPDXRef-Package-numtoa-0.1.0", "relatedSpdxElement": "SPDXRef-Package-redox_termios-0.1.3",
"relationshipType": "DEPENDS_ON", "relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-termion-3.0.0" "spdxElementId": "SPDXRef-Package-termion-4.0.3"
}, },
{ {
"relatedSpdxElement": "SPDXRef-Package-pico-args-0.5.0", "relatedSpdxElement": "SPDXRef-Package-libc-0.2.167",
"relationshipType": "DEPENDS_ON", "relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-pride-0.4.1" "spdxElementId": "SPDXRef-Package-termion-4.0.3"
}, },
{ {
"relatedSpdxElement": "SPDXRef-Package-libc-0.2.155", "relatedSpdxElement": "SPDXRef-Package-pride-0.4.3",
"relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-termion-3.0.0"
},
{
"relatedSpdxElement": "SPDXRef-Package-termion-3.0.0",
"relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-pride-0.4.1"
},
{
"relatedSpdxElement": "SPDXRef-Package-bitflags-1.3.2",
"relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-redox_syscall-0.4.1"
},
{
"relatedSpdxElement": "SPDXRef-Package-pride-0.4.1",
"relationshipType": "GENERATED_FROM", "relationshipType": "GENERATED_FROM",
"spdxElementId": "SPDXRef-File-pride" "spdxElementId": "SPDXRef-File-pride"
}, },
{ {
"relatedSpdxElement": "SPDXRef-Package-libredox-0.0.2", "relatedSpdxElement": "SPDXRef-Package-bitflags-2.6.0",
"relationshipType": "DEPENDS_ON", "relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-termion-3.0.0" "spdxElementId": "SPDXRef-Package-libredox-0.1.3"
}, },
{ {
"relatedSpdxElement": "SPDXRef-Package-redox_syscall-0.4.1", "relatedSpdxElement": "SPDXRef-Package-libc-0.2.167",
"relationshipType": "DEPENDS_ON", "relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-libredox-0.0.2" "spdxElementId": "SPDXRef-Package-libredox-0.1.3"
}, },
{ {
"relatedSpdxElement": "SPDXRef-Package-redox_termios-0.1.3", "relatedSpdxElement": "SPDXRef-Package-libredox-0.1.3",
"relationshipType": "DEPENDS_ON", "relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-termion-3.0.0" "spdxElementId": "SPDXRef-Package-termion-4.0.3"
}, },
{ {
"relatedSpdxElement": "SPDXRef-Package-libc-0.2.155", "relatedSpdxElement": "SPDXRef-Package-pico-args-0.5.0",
"relationshipType": "DEPENDS_ON", "relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-libredox-0.0.2" "spdxElementId": "SPDXRef-Package-pride-0.4.3"
}, },
{ {
"relatedSpdxElement": "SPDXRef-Package-bitflags-2.5.0", "relatedSpdxElement": "SPDXRef-Package-termion-4.0.3",
"relationshipType": "DEPENDS_ON", "relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-libredox-0.0.2" "spdxElementId": "SPDXRef-Package-pride-0.4.3"
},
{
"relatedSpdxElement": "SPDXRef-Package-redox_syscall-0.5.7",
"relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-libredox-0.1.3"
},
{
"relatedSpdxElement": "SPDXRef-Package-numtoa-0.2.4",
"relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-termion-4.0.3"
},
{
"relatedSpdxElement": "SPDXRef-Package-oorandom-11.1.4",
"relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-pride-0.4.3"
},
{
"relatedSpdxElement": "SPDXRef-Package-bitflags-2.6.0",
"relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-redox_syscall-0.5.7"
} }
], ],
"spdxVersion": "SPDX-2.3" "spdxVersion": "SPDX-2.3"

View file

@ -118,7 +118,7 @@ impl Flag {
Flag::Stripes(colors) Flag::Stripes(colors)
=> { => {
let count = colors.len() as u16; let count = colors.len() as u16;
let (width, height) = state.size.get(count * 3, count); let (width, height) = state.size.get((count * 20 + 3) / 6, count);
if height < count { error::too_small(width, height); } if height < count { error::too_small(width, height); }
fg_stripes(colors, width, height) fg_stripes(colors, width, height)
}, },

View file

@ -1,24 +1,24 @@
use std::process::exit; use std::process::exit;
pub fn unmatched_flag(target: String) { pub fn unmatched_flag(target: String) {
println!("pride: no flag {target}"); eprintln!("pride: no flag {target}");
exit(1); exit(1);
} }
pub fn size_missing() { pub fn size_missing() {
println!("pride: size flag requires a value"); eprintln!("pride: size flag requires a value");
exit(2); exit(2);
} }
pub fn size_error(value: &str) { pub fn size_error(value: &str) {
println!("pride: size '{value}' is invalid"); eprintln!("pride: size '{value}' is invalid");
exit(2); exit(2);
} }
pub fn too_small(width: u16, height: u16) { pub fn too_small(width: u16, height: u16) {
println!("pride: this flag must be bigger than {width}x{height}"); eprintln!("pride: this flag must be bigger than {width}x{height}");
exit(3); exit(3);
} }

View file

@ -130,7 +130,7 @@ names:
=> { println!("The gender-nonconforming pride flag.\n\nnames:\n 'gender-nonconforming', 'gendernonconforming', 'gnc'"); }, => { println!("The gender-nonconforming pride flag.\n\nnames:\n 'gender-nonconforming', 'gendernonconforming', 'gnc'"); },
"lesbian" "lesbian" | "wlw"
=> { => {
println!("The 5-stripe lesbian flag designed by Emily Gwen in 2018. println!("The 5-stripe lesbian flag designed by Emily Gwen in 2018.
@ -138,7 +138,9 @@ names:
'lesbian', 'wlw' 'lesbian', 'wlw'
variants: variants:
7-color 7-stripe flag, also designed in 2018 by Emily Gwen"); 7 7-stripe flag, also designed in 2018 by Emily Gwen
7-color
7-stripe");
}, },

View file

@ -1,4 +1,8 @@
//! main method module //! main method module
use std::{
env::var,
time::UNIX_EPOCH
};
use pico_args::Arguments; use pico_args::Arguments;
@ -21,7 +25,7 @@ static VERSION: &str = env!("CARGO_PKG_VERSION");
pub const FLAG_HELP: [&str;2] = [ "-h", "--help" ]; pub const FLAG_HELP: [&str;2] = [ "-h", "--help" ];
pub const FLAG_LIST: [&str;2] = [ "-l", "--list" ]; pub const FLAG_LIST: [&str;2] = [ "-l", "--list" ];
pub const FLAG_SIZE: [&str;2] = [ "-s", "--size"]; pub const FLAG_SIZE: [&str;2] = [ "-s", "--size" ];
pub const FLAG_VERSION: [&str;2] = [ "-v", "--version" ]; pub const FLAG_VERSION: [&str;2] = [ "-v", "--version" ];
fn main() { fn main() {
@ -50,8 +54,25 @@ fn main() {
let state = State::new(&mut args); let state = State::new(&mut args);
let subcommand = args.subcommand().unwrap(); let ( subcommand, variant ) =
let variant = args.subcommand().unwrap(); if let Ok(Some(subcommand)) = args.subcommand() { ( Some(subcommand), args.subcommand().unwrap()) }
else if let Ok(default) = var("PRIDE_DEFAULT") {
if default.is_empty() { ( None, None ) }
else if default.contains(';') {
let split: Vec<&str> = default.split(';').collect();
if let Ok(time) = UNIX_EPOCH.elapsed() {
let index = oorandom::Rand32::new(time.as_secs()).rand_u32();
let chosen = split[index as usize % split.len()].to_owned();
if chosen.contains(' ') {
let split: Vec<&str> = chosen.split(' ').collect();
( Some(split[0].to_owned()), Some(split[1].to_owned()) )
} else { ( Some(chosen), None ) }
} else { ( None, None ) }
} else if default.contains(' ') {
let split: Vec<&str> = default.split(' ').collect();
( Some(split[0].to_owned()), Some(split[1].to_owned()) )
} else { ( Some(default), None ) }
} else { ( None, None ) };
// get color vec from matched flag // get color vec from matched flag
let flag: Flag = match subcommand.as_deref() { let flag: Flag = match subcommand.as_deref() {
@ -140,7 +161,7 @@ fn main() {
Some("lesbian" | "wlw") Some("lesbian" | "wlw")
=> { => {
match variant.as_deref() { match variant.as_deref() {
Some("7-color") Some("7" | "7-color" | "7-stripe")
=> variant::lesbian_7(), => variant::lesbian_7(),
_ _
=> flag::lesbian() => flag::lesbian()