Compare commits
6 commits
Author | SHA1 | Date | |
---|---|---|---|
715fa605a6 | |||
a161aab0ca | |||
a62316c9f5 | |||
d41df133b1 | |||
9bf53f1d27 | |||
b91056d68a |
5 changed files with 146 additions and 122 deletions
|
@ -1,11 +1,11 @@
|
|||
[package]
|
||||
name = "pride"
|
||||
version = "0.4.2"
|
||||
version = "0.4.3"
|
||||
edition = "2021"
|
||||
authors = [ "Valerie Wolfe <sleeplessval@gmail.com>" ]
|
||||
description = "Pride flags in the terminal."
|
||||
homepage = "https://git.vwolfe.io/valerie/pride"
|
||||
repository = "https://git.vwolfe.io/valerie/pride"
|
||||
homepage = "https://git.sleeplessval.io/valerie/pride"
|
||||
repository = "https://git.sleeplessval.io/valerie/pride"
|
||||
license = "MIT"
|
||||
categories = [ "command-line-utilities" ]
|
||||
keywords = [ "lgbt", "pride", "cli" ]
|
||||
|
@ -19,6 +19,7 @@ name = "pride"
|
|||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
oorandom = '11.1.4'
|
||||
pico-args = "0.5.0"
|
||||
termion = "4.0.3"
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
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
|
||||
|
||||
|
@ -16,7 +16,7 @@ slant symbols, and therefore require use of a Powerline font, such as [Fira Code
|
|||
|
||||
<details>
|
||||
<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>.
|
||||
</details>
|
||||
|
||||
|
|
|
@ -85,9 +85,13 @@ The transgender pride flag designed by Monica Helms in 1999.
|
|||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width Ds
|
||||
.It PRIDE_DEFAULT
|
||||
A string containing the name of a flag to use as the default when no
|
||||
A string containing the name of one or more flags to use as the default when no
|
||||
.Ar flag
|
||||
argument is provided.
|
||||
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
|
||||
.Bl -tag -width Ds
|
||||
|
|
212
sbom.xml
212
sbom.xml
|
@ -1,13 +1,13 @@
|
|||
{
|
||||
"SPDXID": "SPDXRef-DOCUMENT",
|
||||
"creationInfo": {
|
||||
"created": "2024-07-05T20:16:51.403Z",
|
||||
"created": "2024-12-13T16:02:17.260Z",
|
||||
"creators": [
|
||||
"Tool: cargo-sbom-v0.8.4"
|
||||
]
|
||||
},
|
||||
"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": [
|
||||
{
|
||||
"SPDXID": "SPDXRef-File-pride",
|
||||
|
@ -21,70 +21,62 @@
|
|||
"name": "pride",
|
||||
"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",
|
||||
"downloadLocation": "registry+https://github.com/rust-lang/crates.io-index",
|
||||
"externalRefs": [
|
||||
{
|
||||
"referenceCategory": "PACKAGE-MANAGER",
|
||||
"referenceLocator": "pkg:cargo/redox_syscall@0.4.1",
|
||||
"referenceLocator": "pkg:cargo/redox_syscall@0.5.7",
|
||||
"referenceType": "purl"
|
||||
}
|
||||
],
|
||||
"licenseConcluded": "MIT",
|
||||
"licenseDeclared": "MIT",
|
||||
"name": "redox_syscall",
|
||||
"versionInfo": "0.4.1"
|
||||
"versionInfo": "0.5.7"
|
||||
},
|
||||
{
|
||||
"SPDXID": "SPDXRef-Package-libredox-0.0.2",
|
||||
"description": "Redox stable ABI",
|
||||
"SPDXID": "SPDXRef-Package-pride-0.4.3",
|
||||
"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",
|
||||
"externalRefs": [
|
||||
{
|
||||
"referenceCategory": "PACKAGE-MANAGER",
|
||||
"referenceLocator": "pkg:cargo/libredox@0.0.2",
|
||||
"referenceLocator": "pkg:cargo/termion@4.0.3",
|
||||
"referenceType": "purl"
|
||||
}
|
||||
],
|
||||
"licenseConcluded": "MIT",
|
||||
"licenseDeclared": "MIT",
|
||||
"name": "libredox",
|
||||
"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"
|
||||
"name": "termion",
|
||||
"versionInfo": "4.0.3"
|
||||
},
|
||||
{
|
||||
"SPDXID": "SPDXRef-Package-redox_termios-0.1.3",
|
||||
|
@ -103,45 +95,30 @@
|
|||
"versionInfo": "0.1.3"
|
||||
},
|
||||
{
|
||||
"SPDXID": "SPDXRef-Package-numtoa-0.1.0",
|
||||
"description": "Convert numbers into stack-allocated byte arrays",
|
||||
"SPDXID": "SPDXRef-Package-libc-0.2.167",
|
||||
"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/numtoa@0.1.0",
|
||||
"referenceLocator": "pkg:cargo/libc@0.2.167",
|
||||
"referenceType": "purl"
|
||||
}
|
||||
],
|
||||
"homepage": "https://github.com/rust-lang/libc",
|
||||
"licenseConcluded": "MIT OR Apache-2.0",
|
||||
"licenseDeclared": "MIT OR Apache-2.0",
|
||||
"name": "numtoa",
|
||||
"versionInfo": "0.1.0"
|
||||
"name": "libc",
|
||||
"versionInfo": "0.2.167"
|
||||
},
|
||||
{
|
||||
"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",
|
||||
"SPDXID": "SPDXRef-Package-bitflags-2.6.0",
|
||||
"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@2.5.0",
|
||||
"referenceLocator": "pkg:cargo/bitflags@2.6.0",
|
||||
"referenceType": "purl"
|
||||
}
|
||||
],
|
||||
|
@ -149,17 +126,39 @@
|
|||
"licenseConcluded": "MIT OR Apache-2.0",
|
||||
"licenseDeclared": "MIT OR Apache-2.0",
|
||||
"name": "bitflags",
|
||||
"versionInfo": "2.5.0"
|
||||
"versionInfo": "2.6.0"
|
||||
},
|
||||
{
|
||||
"SPDXID": "SPDXRef-Package-pride-0.4.1",
|
||||
"description": "Pride flags in the terminal.",
|
||||
"downloadLocation": "NONE",
|
||||
"homepage": "https://git.vwolfe.io/valerie/pride",
|
||||
"SPDXID": "SPDXRef-Package-libredox-0.1.3",
|
||||
"description": "Redox stable ABI",
|
||||
"downloadLocation": "registry+https://github.com/rust-lang/crates.io-index",
|
||||
"externalRefs": [
|
||||
{
|
||||
"referenceCategory": "PACKAGE-MANAGER",
|
||||
"referenceLocator": "pkg:cargo/libredox@0.1.3",
|
||||
"referenceType": "purl"
|
||||
}
|
||||
],
|
||||
"licenseConcluded": "MIT",
|
||||
"licenseDeclared": "MIT",
|
||||
"name": "pride",
|
||||
"versionInfo": "0.4.1"
|
||||
"name": "libredox",
|
||||
"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",
|
||||
|
@ -180,59 +179,64 @@
|
|||
],
|
||||
"relationships": [
|
||||
{
|
||||
"relatedSpdxElement": "SPDXRef-Package-numtoa-0.1.0",
|
||||
"relatedSpdxElement": "SPDXRef-Package-redox_termios-0.1.3",
|
||||
"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",
|
||||
"spdxElementId": "SPDXRef-Package-pride-0.4.1"
|
||||
"spdxElementId": "SPDXRef-Package-termion-4.0.3"
|
||||
},
|
||||
{
|
||||
"relatedSpdxElement": "SPDXRef-Package-libc-0.2.155",
|
||||
"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",
|
||||
"relatedSpdxElement": "SPDXRef-Package-pride-0.4.3",
|
||||
"relationshipType": "GENERATED_FROM",
|
||||
"spdxElementId": "SPDXRef-File-pride"
|
||||
},
|
||||
{
|
||||
"relatedSpdxElement": "SPDXRef-Package-libredox-0.0.2",
|
||||
"relatedSpdxElement": "SPDXRef-Package-bitflags-2.6.0",
|
||||
"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",
|
||||
"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",
|
||||
"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",
|
||||
"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",
|
||||
"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"
|
||||
|
|
37
src/main.rs
37
src/main.rs
|
@ -1,5 +1,8 @@
|
|||
//! main method module
|
||||
use std::env::var;
|
||||
use std::{
|
||||
env::var,
|
||||
time::UNIX_EPOCH
|
||||
};
|
||||
|
||||
use pico_args::Arguments;
|
||||
|
||||
|
@ -20,10 +23,10 @@ use crate::{
|
|||
|
||||
static VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
pub const FLAG_HELP: [&str;2] = [ "-h", "--help" ];
|
||||
pub const FLAG_LIST: [&str;2] = [ "-l", "--list" ];
|
||||
pub const FLAG_SIZE: [&str;2] = [ "-s", "--size"];
|
||||
pub const FLAG_VERSION: [&str;2] = [ "-v", "--version" ];
|
||||
pub const FLAG_HELP: [&str;2] = [ "-h", "--help" ];
|
||||
pub const FLAG_LIST: [&str;2] = [ "-l", "--list" ];
|
||||
pub const FLAG_SIZE: [&str;2] = [ "-s", "--size" ];
|
||||
pub const FLAG_VERSION: [&str;2] = [ "-v", "--version" ];
|
||||
|
||||
fn main() {
|
||||
// collect args
|
||||
|
@ -51,13 +54,25 @@ fn main() {
|
|||
|
||||
let state = State::new(&mut args);
|
||||
|
||||
let subcommand =
|
||||
if let Ok(Some(subcommand)) = args.subcommand() { Some(subcommand) }
|
||||
let ( subcommand, variant ) =
|
||||
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 }
|
||||
else { Some(default) }
|
||||
} else { None };
|
||||
let variant = args.subcommand().unwrap();
|
||||
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
|
||||
let flag: Flag = match subcommand.as_deref() {
|
||||
|
|
Loading…
Reference in a new issue