Skip to content

Commit

Permalink
release: 0.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
joshstoik1 committed Oct 17, 2024
2 parents bcb7796 + 3442970 commit dc557fc
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 65 deletions.
16 changes: 8 additions & 8 deletions CREDITS.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Project Dependencies
Package: cargo-bashman
Version: 0.5.0
Generated: 2024-10-08 19:58:02 UTC
Version: 0.5.1
Generated: 2024-10-17 20:05:20 UTC

| Package | Version | Author(s) | License |
| ---- | ---- | ---- | ---- |
| [adbyss_psl](https://github.com/Blobfolio/adbyss) | 0.13.0 | [Josh Stoik](mailto:[email protected]) | WTFPL |
| [adbyss_psl](https://github.com/Blobfolio/adbyss) | 0.13.1 | [Josh Stoik](mailto:[email protected]) | WTFPL |
| [adler2](https://github.com/oyvindln/adler2) | 2.0.0 | [Jonas Schievink](mailto:[email protected]) and [oyvindln](mailto:[email protected]) | 0BSD, Apache-2.0, or MIT |
| [ahash](https://github.com/tkaitchuck/ahash) | 0.8.11 | [Tom Kaitchuck](mailto:[email protected]) | Apache-2.0 or MIT |
| [argyle](https://github.com/Blobfolio/argyle) | 0.8.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [bashman_core](https://github.com/Blobfolio/bashman) | 0.5.0 | [Josh Stoik](mailto:[email protected]) | WTFPL |
| [argyle](https://github.com/Blobfolio/argyle) | 0.10.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [bashman_core](https://github.com/Blobfolio/bashman) | 0.5.1 | [Josh Stoik](mailto:[email protected]) | WTFPL |
| [camino](https://github.com/camino-rs/camino) | 1.1.9 | [Without Boats](mailto:[email protected]), [Ashley Williams](mailto:[email protected]), [Steve Klabnik](mailto:[email protected]), and [Rain](mailto:[email protected]) | Apache-2.0 or MIT |
| [cargo-platform](https://github.com/rust-lang/cargo) | 0.1.8 | | Apache-2.0 or MIT |
| [cargo_metadata](https://github.com/oli-obk/cargo_metadata) | 0.18.1 | [Oliver Schneider](mailto:[email protected]) | MIT |
Expand All @@ -19,7 +19,7 @@
| [displaydoc](https://github.com/yaahc/displaydoc) | 0.2.5 | [Jane Lusby](mailto:[email protected]) | Apache-2.0 or MIT |
| [equivalent](https://github.com/cuviper/equivalent) | 1.0.1 | | Apache-2.0 or MIT |
| [flate2](https://github.com/rust-lang/flate2-rs) | 1.0.34 | [Alex Crichton](mailto:[email protected]) and [Josh Triplett](mailto:[email protected]) | Apache-2.0 or MIT |
| [fyi_msg](https://github.com/Blobfolio/fyi) | 0.14.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [fyi_msg](https://github.com/Blobfolio/fyi) | 1.1.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [hashbrown](https://github.com/rust-lang/hashbrown) | 0.15.0 | [Amanieu d'Antras](mailto:[email protected]) | Apache-2.0 or MIT |
| [icu_collections](https://github.com/unicode-org/icu4x) | 1.5.0 | The ICU4X Project Developers | Unicode-3.0 |
| [icu_locid](https://github.com/unicode-org/icu4x) | 1.5.0 | The ICU4X Project Developers | Unicode-3.0 |
Expand All @@ -38,13 +38,13 @@
| [memchr](https://github.com/BurntSushi/memchr) | 2.7.4 | [Andrew Gallant](mailto:[email protected]) and bluss | MIT or Unlicense |
| [miniz_oxide](https://github.com/Frommi/miniz_oxide/tree/master/miniz_oxide) | 0.8.0 | [Frommi](mailto:[email protected]) and [oyvindln](mailto:[email protected]) | Apache-2.0, MIT, or Zlib |
| [oxford_join](https://github.com/Blobfolio/oxford_join) | 0.4.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
| [proc-macro2](https://github.com/dtolnay/proc-macro2) | 1.0.87 | [David Tolnay](mailto:[email protected]) and [Alex Crichton](mailto:[email protected]) | Apache-2.0 or MIT |
| [proc-macro2](https://github.com/dtolnay/proc-macro2) | 1.0.88 | [David Tolnay](mailto:[email protected]) and [Alex Crichton](mailto:[email protected]) | Apache-2.0 or MIT |
| [quote](https://github.com/dtolnay/quote) | 1.0.37 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
| [ryu](https://github.com/dtolnay/ryu) | 1.0.18 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or BSL-1.0 |
| [semver](https://github.com/dtolnay/semver) | 1.0.23 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
| [serde](https://github.com/serde-rs/serde) | 1.0.210 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
| [serde_derive](https://github.com/serde-rs/serde) | 1.0.210 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
| [serde_json](https://github.com/serde-rs/json) | 1.0.128 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
| [serde_json](https://github.com/serde-rs/json) | 1.0.129 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
| [serde_spanned](https://github.com/toml-rs/toml) | 0.6.8 | | Apache-2.0 or MIT |
| [smallvec](https://github.com/servo/rust-smallvec) | 1.13.2 | The Servo Project Developers | Apache-2.0 or MIT |
| [stable_deref_trait](https://github.com/storyyeller/stable_deref_trait) | 1.2.0 | [Robert Grosse](mailto:[email protected]) | Apache-2.0 or MIT |
Expand Down
9 changes: 6 additions & 3 deletions bashman/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-bashman"
version = "0.5.0"
version = "0.5.1"
license = "WTFPL"
authors = ["Josh Stoik <[email protected]>"]
edition = "2021"
Expand Down Expand Up @@ -64,9 +64,12 @@ description = "Path to the Cargo.toml file to use."
label = "<Cargo.toml>"
path = true

[build-dependencies]
argyle = "0.10.*"

[dependencies]
argyle = "0.8.*"
fyi_msg = "0.14.*"
argyle = "0.10.*"
fyi_msg = "1.1.*"

[dependencies.bashman_core]
path = "../bashman_core"
34 changes: 34 additions & 0 deletions bashman/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*!
# Cargo Bashman: Build
*/

use argyle::KeyWordsBuilder;
use std::path::PathBuf;



/// # Set Up CLI Arguments.
pub fn main() {
let mut builder = KeyWordsBuilder::default();
builder.push_keys([
"-h", "--help",
"--no-bash",
"--no-credits",
"--no-man",
"-V", "--version",
]);
builder.push_keys_with_values([
"-f", "--features",
"-m", "--manifest-path",
]);
builder.save(out_path("argyle.rs"));
}

/// # Output Path.
///
/// Append the sub-path to OUT_DIR and return it.
fn out_path(stub: &str) -> PathBuf {
std::fs::canonicalize(std::env::var("OUT_DIR").expect("Missing OUT_DIR."))
.expect("Missing OUT_DIR.")
.join(stub)
}
71 changes: 33 additions & 38 deletions bashman/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,7 @@



use argyle::{
Argue,
ArgyleError,
FLAG_HELP,
FLAG_VERSION,
};
use argyle::Argument;
use bashman_core::{
BashManError,
FLAG_ALL,
Expand All @@ -75,10 +70,10 @@ use std::path::PathBuf;
fn main() {
match _main() {
Ok(()) => {},
Err(BashManError::Argue(ArgyleError::WantsVersion)) => {
Err(BashManError::PrintVersion) => {
println!(concat!("Cargo BashMan v", env!("CARGO_PKG_VERSION")));
},
Err(BashManError::Argue(ArgyleError::WantsHelp)) => { helper(); },
Err(BashManError::PrintHelp) => { helper(); },
Err(e) => { Msg::error(e.to_string()).die(1); },
}
}
Expand All @@ -87,41 +82,41 @@ fn main() {
/// # Actual main.
fn _main() -> Result<(), BashManError> {
// Parse CLI arguments.
let args = Argue::new(FLAG_HELP | FLAG_VERSION).map_err(BashManError::Argue)?;

// Check for invalid CLI options.
if let Some(boo) = args.check_keys(
&[b"--no-bash", b"--no-credits", b"--no-man"],
&[b"--features", b"--manifest-path", b"-f", b"-m"],
) {
return Err(BashManError::InvalidCli(String::from_utf8_lossy(boo).into()));
}
let args = argyle::args()
.with_keywords(include!(concat!(env!("OUT_DIR"), "/argyle.rs")));

let mut flags: u8 = FLAG_ALL;
if args.switch(b"--no-bash") {
flags &= ! FLAG_BASH;
}
if args.switch(b"--no-credits") {
flags &= ! FLAG_CREDITS;
}
if args.switch(b"--no-man") {
flags &= ! FLAG_MAN;
}

let features = args.option2(b"-f", b"--features").and_then(|x| std::str::from_utf8(x).ok());

let manifest =
if let Some(p) = args.option2_os(b"-m", b"--manifest-path") {
PathBuf::from(p)
let mut features = None;
let mut manifest = None;
for arg in args {
match arg {
Argument::Key("--no-bash") => { flags &= ! FLAG_BASH; },
Argument::Key("--no-credits") => { flags &= ! FLAG_CREDITS; },
Argument::Key("--no-man") => { flags &= ! FLAG_MAN; },

Argument::Key("-h" | "--help") => return Err(BashManError::PrintHelp),
Argument::Key("-V" | "--version") => return Err(BashManError::PrintVersion),

Argument::KeyWithValue("-f" | "--features", s) => { features.replace(s); }
Argument::KeyWithValue("-m" | "--manifest-path", s) => {
manifest.replace(PathBuf::from(s));
},

// Nothing else is expected.
Argument::Other(s) => return Err(BashManError::InvalidCli(s.into_boxed_str())),
Argument::InvalidUtf8(s) => return Err(BashManError::InvalidCli(s.to_string_lossy().into_owned().into_boxed_str())),
_ => {},
}
else {
std::env::current_dir()
.map_err(|_| BashManError::InvalidManifest)?
.join("Cargo.toml")
};
}

bashman_core::parse(manifest, flags, features)?;
let manifest = match manifest {
Some(m) => m,
None => std::env::current_dir()
.map_err(|_| BashManError::InvalidManifest)?
.join("Cargo.toml"),
};

bashman_core::parse(manifest, flags, features.as_deref())?;
Ok(())
}

Expand Down
6 changes: 2 additions & 4 deletions bashman_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bashman_core"
version = "0.5.0"
version = "0.5.1"
license = "WTFPL"
authors = ["Josh Stoik <[email protected]>"]
edition = "2021"
Expand All @@ -10,11 +10,9 @@ publish = false

[dependencies]
adbyss_psl = "0.13.*"
argyle = "0.8.*"
cargo_metadata = "=0.18.1"
flate2 = "1.0.*"
fyi_msg = "0.14.*"
indexmap = "2.6.*"
fyi_msg = "1.1.*"
oxford_join = "0.4.*"
trimothy = "0.3.*"
utc2k = "0.10.*"
Expand Down
28 changes: 23 additions & 5 deletions bashman_core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,74 @@
# `Cargo BashMan` - Error
*/

use argyle::ArgyleError;
use std::error::Error;
use std::fmt;



#[derive(Debug, Clone)]
#[derive(Debug, Clone, Eq, PartialEq)]
/// # Error.
pub enum BashManError {
/// # Argue Passthru.
Argue(ArgyleError),
/// # Invalid Bash output directory.
InvalidBashDir,

/// # Invalid Credits output directory.
InvalidCreditsDir,

/// # Invalid CLI Option.
InvalidCli(Box<str>),

/// # Invalid flag.
InvalidFlag,

/// # Invalid item.
InvalidItem,

/// # Invalid/missing Cargo.lock.
InvalidLock,

/// # Invalid Man output directory.
InvalidManDir,

/// # Invalid manifest.
InvalidManifest,

/// # Invalid section.
InvalidSection,

/// # Invalid subcommand.
InvalidSubCommand(Box<str>),

/// # Missing subcommand.
MissingSubCommand,

/// # Parse manifest.
ParseManifest(Box<str>),

/// # Write Bash.
WriteBash,

/// # Write Credits.
WriteCredits,

/// # Write Man.
WriteMan,

/// # Write Man.
WriteSubMan(Box<str>),

/// # Print Help (Not an Error).
PrintHelp,

/// # Print Version (Not an Error).
PrintVersion,
}

impl Error for BashManError {}

impl fmt::Display for BashManError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Argue(src) => f.write_str(src.as_str()),
Self::InvalidBashDir => f.write_str("Invalid BASH output directory."),
Self::InvalidCli(s) => f.write_fmt(format_args!("Invalid/unknown CLI option: {s}")),
Self::InvalidCreditsDir => f.write_str("Invalid credits output directory."),
Expand All @@ -69,6 +86,7 @@ impl fmt::Display for BashManError {
Self::WriteCredits => f.write_str("Unable to write CREDITS.md."),
Self::WriteMan => f.write_str("Unable to write Manual(s)."),
Self::WriteSubMan(s) => f.write_fmt(format_args!("Unable to write Man for {s:?}.")),
Self::PrintHelp | Self::PrintVersion => Ok(()),
}
}
}
12 changes: 7 additions & 5 deletions bashman_core/src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ use crate::{
DataOption,
More,
};
use indexmap::IndexMap;
use serde::{
Deserialize,
Deserializer,
};
use std::path::{
Path,
PathBuf,
use std::{
collections::BTreeMap,
path::{
Path,
PathBuf,
},
};
use trimothy::TrimMut;

Expand Down Expand Up @@ -403,7 +405,7 @@ impl<'a> TryFrom<&'a Raw> for Command<'a> {
return src.parse_single();
}

let mut subcmds: IndexMap<&'_ str, (&'_ str, &'_ str, &'_ str, Vec::<DataKind<'_>>)> = src.package.metadata.subcommands.iter()
let mut subcmds: BTreeMap<&'_ str, (&'_ str, &'_ str, &'_ str, Vec::<DataKind<'_>>)> = src.package.metadata.subcommands.iter()
.map(|y|
(
y.cmd.as_str(),
Expand Down
4 changes: 2 additions & 2 deletions release/man/cargo-bashman.1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.TH "CARGO BASHMAN" "1" "October 2024" "cargo\-bashman v0.5.0" "User Commands"
.TH "CARGO BASHMAN" "1" "October 2024" "cargo\-bashman v0.5.1" "User Commands"
.SH NAME
CARGO BASHMAN \- Manual page for cargo\-bashman v0.5.0.
CARGO BASHMAN \- Manual page for cargo\-bashman v0.5.1.
.SH DESCRIPTION
A Cargo plugin to generate BASH completions and MAN pages.
.SS USAGE:
Expand Down

0 comments on commit dc557fc

Please sign in to comment.