Compare commits

..

No commits in common. "main" and "v0.4.2" have entirely different histories.
main ... v0.4.2

5 changed files with 126 additions and 150 deletions

View file

@ -1,11 +1,11 @@
[package] [package]
name = "pride" name = "pride"
version = "0.4.3" version = "0.4.2"
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.sleeplessval.io/valerie/pride" homepage = "https://git.vwolfe.io/valerie/pride"
repository = "https://git.sleeplessval.io/valerie/pride" repository = "https://git.vwolfe.io/valerie/pride"
license = "MIT" license = "MIT"
categories = [ "command-line-utilities" ] categories = [ "command-line-utilities" ]
keywords = [ "lgbt", "pride", "cli" ] keywords = [ "lgbt", "pride", "cli" ]
@ -19,7 +19,6 @@ 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 = "4.0.3" termion = "4.0.3"

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.sleeplessval.io/valerie/pride/wiki/Flags). A list of currently implemented flags is available on the [project wiki](https://git.vwolfe.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.sleeplessval.io/valerie/pride/releases/">releases page</a> Copy the compiled binary from the <a href="https://git.vwolfe.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

@ -85,13 +85,9 @@ The transgender pride flag designed by Monica Helms in 1999.
.Sh ENVIRONMENT .Sh ENVIRONMENT
.Bl -tag -width Ds .Bl -tag -width Ds
.It PRIDE_DEFAULT .It PRIDE_DEFAULT
A string containing the name of one or more flags to use as the default when no A string containing the name of a flag to use as the default when no
.Ar flag .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 argument is provided.
.Ar flag
and
.Ar variant
arguments.
.El .El
.Sh EXIT STATUS .Sh EXIT STATUS
.Bl -tag -width Ds .Bl -tag -width Ds

220
sbom.xml
View file

@ -1,13 +1,13 @@
{ {
"SPDXID": "SPDXRef-DOCUMENT", "SPDXID": "SPDXRef-DOCUMENT",
"creationInfo": { "creationInfo": {
"created": "2024-12-13T16:02:17.260Z", "created": "2024-07-05T20:16:51.403Z",
"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-93ad73c9-b337-4ad0-bd63-92e9b7d1a2d8", "documentNamespace": "https://spdx.org/spdxdocs/pride-6150510e-b518-43f0-aa53-3e2795909cc2",
"files": [ "files": [
{ {
"SPDXID": "SPDXRef-File-pride", "SPDXID": "SPDXRef-File-pride",
@ -21,62 +21,70 @@
"name": "pride", "name": "pride",
"packages": [ "packages": [
{ {
"SPDXID": "SPDXRef-Package-oorandom-11.1.4", "SPDXID": "SPDXRef-Package-redox_syscall-0.4.1",
"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.5.7", "referenceLocator": "pkg:cargo/redox_syscall@0.4.1",
"referenceType": "purl" "referenceType": "purl"
} }
], ],
"licenseConcluded": "MIT", "licenseConcluded": "MIT",
"licenseDeclared": "MIT", "licenseDeclared": "MIT",
"name": "redox_syscall", "name": "redox_syscall",
"versionInfo": "0.5.7" "versionInfo": "0.4.1"
}, },
{ {
"SPDXID": "SPDXRef-Package-pride-0.4.3", "SPDXID": "SPDXRef-Package-libredox-0.0.2",
"description": "Pride flags in the terminal.", "description": "Redox stable ABI",
"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/termion@4.0.3", "referenceLocator": "pkg:cargo/libredox@0.0.2",
"referenceType": "purl" "referenceType": "purl"
} }
], ],
"licenseConcluded": "MIT", "licenseConcluded": "MIT",
"licenseDeclared": "MIT", "licenseDeclared": "MIT",
"name": "termion", "name": "libredox",
"versionInfo": "4.0.3" "versionInfo": "0.0.2"
},
{
"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",
@ -95,30 +103,45 @@
"versionInfo": "0.1.3" "versionInfo": "0.1.3"
}, },
{ {
"SPDXID": "SPDXRef-Package-libc-0.2.167", "SPDXID": "SPDXRef-Package-numtoa-0.1.0",
"description": "Raw FFI bindings to platform libraries like libc.\n", "description": "Convert numbers into stack-allocated byte arrays",
"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/libc@0.2.167", "referenceLocator": "pkg:cargo/numtoa@0.1.0",
"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": "libc", "name": "numtoa",
"versionInfo": "0.2.167" "versionInfo": "0.1.0"
}, },
{ {
"SPDXID": "SPDXRef-Package-bitflags-2.6.0", "SPDXID": "SPDXRef-Package-termion-3.0.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.6.0", "referenceLocator": "pkg:cargo/bitflags@2.5.0",
"referenceType": "purl" "referenceType": "purl"
} }
], ],
@ -126,39 +149,17 @@
"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.6.0" "versionInfo": "2.5.0"
}, },
{ {
"SPDXID": "SPDXRef-Package-libredox-0.1.3", "SPDXID": "SPDXRef-Package-pride-0.4.1",
"description": "Redox stable ABI", "description": "Pride flags in the terminal.",
"downloadLocation": "registry+https://github.com/rust-lang/crates.io-index", "downloadLocation": "NONE",
"externalRefs": [ "homepage": "https://git.vwolfe.io/valerie/pride",
{
"referenceCategory": "PACKAGE-MANAGER",
"referenceLocator": "pkg:cargo/libredox@0.1.3",
"referenceType": "purl"
}
],
"licenseConcluded": "MIT", "licenseConcluded": "MIT",
"licenseDeclared": "MIT", "licenseDeclared": "MIT",
"name": "libredox", "name": "pride",
"versionInfo": "0.1.3" "versionInfo": "0.4.1"
},
{
"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",
@ -179,64 +180,59 @@
], ],
"relationships": [ "relationships": [
{ {
"relatedSpdxElement": "SPDXRef-Package-redox_termios-0.1.3", "relatedSpdxElement": "SPDXRef-Package-numtoa-0.1.0",
"relationshipType": "DEPENDS_ON", "relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-termion-4.0.3" "spdxElementId": "SPDXRef-Package-termion-3.0.0"
},
{
"relatedSpdxElement": "SPDXRef-Package-libc-0.2.167",
"relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-termion-4.0.3"
},
{
"relatedSpdxElement": "SPDXRef-Package-pride-0.4.3",
"relationshipType": "GENERATED_FROM",
"spdxElementId": "SPDXRef-File-pride"
},
{
"relatedSpdxElement": "SPDXRef-Package-bitflags-2.6.0",
"relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-libredox-0.1.3"
},
{
"relatedSpdxElement": "SPDXRef-Package-libc-0.2.167",
"relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-libredox-0.1.3"
},
{
"relatedSpdxElement": "SPDXRef-Package-libredox-0.1.3",
"relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-termion-4.0.3"
}, },
{ {
"relatedSpdxElement": "SPDXRef-Package-pico-args-0.5.0", "relatedSpdxElement": "SPDXRef-Package-pico-args-0.5.0",
"relationshipType": "DEPENDS_ON", "relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-pride-0.4.3" "spdxElementId": "SPDXRef-Package-pride-0.4.1"
}, },
{ {
"relatedSpdxElement": "SPDXRef-Package-termion-4.0.3", "relatedSpdxElement": "SPDXRef-Package-libc-0.2.155",
"relationshipType": "DEPENDS_ON", "relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-pride-0.4.3" "spdxElementId": "SPDXRef-Package-termion-3.0.0"
}, },
{ {
"relatedSpdxElement": "SPDXRef-Package-redox_syscall-0.5.7", "relatedSpdxElement": "SPDXRef-Package-termion-3.0.0",
"relationshipType": "DEPENDS_ON", "relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-libredox-0.1.3" "spdxElementId": "SPDXRef-Package-pride-0.4.1"
}, },
{ {
"relatedSpdxElement": "SPDXRef-Package-numtoa-0.2.4", "relatedSpdxElement": "SPDXRef-Package-bitflags-1.3.2",
"relationshipType": "DEPENDS_ON", "relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-termion-4.0.3" "spdxElementId": "SPDXRef-Package-redox_syscall-0.4.1"
}, },
{ {
"relatedSpdxElement": "SPDXRef-Package-oorandom-11.1.4", "relatedSpdxElement": "SPDXRef-Package-pride-0.4.1",
"relationshipType": "DEPENDS_ON", "relationshipType": "GENERATED_FROM",
"spdxElementId": "SPDXRef-Package-pride-0.4.3" "spdxElementId": "SPDXRef-File-pride"
}, },
{ {
"relatedSpdxElement": "SPDXRef-Package-bitflags-2.6.0", "relatedSpdxElement": "SPDXRef-Package-libredox-0.0.2",
"relationshipType": "DEPENDS_ON", "relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-redox_syscall-0.5.7" "spdxElementId": "SPDXRef-Package-termion-3.0.0"
},
{
"relatedSpdxElement": "SPDXRef-Package-redox_syscall-0.4.1",
"relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-libredox-0.0.2"
},
{
"relatedSpdxElement": "SPDXRef-Package-redox_termios-0.1.3",
"relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-termion-3.0.0"
},
{
"relatedSpdxElement": "SPDXRef-Package-libc-0.2.155",
"relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-libredox-0.0.2"
},
{
"relatedSpdxElement": "SPDXRef-Package-bitflags-2.5.0",
"relationshipType": "DEPENDS_ON",
"spdxElementId": "SPDXRef-Package-libredox-0.0.2"
} }
], ],
"spdxVersion": "SPDX-2.3" "spdxVersion": "SPDX-2.3"

View file

@ -1,8 +1,5 @@
//! main method module //! main method module
use std::{ use std::env::var;
env::var,
time::UNIX_EPOCH
};
use pico_args::Arguments; use pico_args::Arguments;
@ -23,10 +20,10 @@ use crate::{
static VERSION: &str = env!("CARGO_PKG_VERSION"); 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() {
// collect args // collect args
@ -54,25 +51,13 @@ fn main() {
let state = State::new(&mut args); let state = State::new(&mut args);
let ( subcommand, variant ) = let subcommand =
if let Ok(Some(subcommand)) = args.subcommand() { ( Some(subcommand), args.subcommand().unwrap()) } if let Ok(Some(subcommand)) = args.subcommand() { Some(subcommand) }
else if let Ok(default) = var("PRIDE_DEFAULT") { else if let Ok(default) = var("PRIDE_DEFAULT") {
if default.is_empty() { ( None, None ) } if default.is_empty() { None }
else if default.contains(';') { else { Some(default) }
let split: Vec<&str> = default.split(';').collect(); } else { None };
if let Ok(time) = UNIX_EPOCH.elapsed() { let variant = args.subcommand().unwrap();
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() {