Skip to content

Commit dc557fc

Browse files
committed
release: 0.5.1
2 parents bcb7796 + 3442970 commit dc557fc

File tree

8 files changed

+115
-65
lines changed

8 files changed

+115
-65
lines changed

CREDITS.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Project Dependencies
22
Package: cargo-bashman
3-
Version: 0.5.0
4-
Generated: 2024-10-08 19:58:02 UTC
3+
Version: 0.5.1
4+
Generated: 2024-10-17 20:05:20 UTC
55

66
| Package | Version | Author(s) | License |
77
| ---- | ---- | ---- | ---- |
8-
| [adbyss_psl](https://github.com/Blobfolio/adbyss) | 0.13.0 | [Josh Stoik](mailto:[email protected]) | WTFPL |
8+
| [adbyss_psl](https://github.com/Blobfolio/adbyss) | 0.13.1 | [Josh Stoik](mailto:[email protected]) | WTFPL |
99
| [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 |
1010
| [ahash](https://github.com/tkaitchuck/ahash) | 0.8.11 | [Tom Kaitchuck](mailto:[email protected]) | Apache-2.0 or MIT |
11-
| [argyle](https://github.com/Blobfolio/argyle) | 0.8.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
12-
| [bashman_core](https://github.com/Blobfolio/bashman) | 0.5.0 | [Josh Stoik](mailto:[email protected]) | WTFPL |
11+
| [argyle](https://github.com/Blobfolio/argyle) | 0.10.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
12+
| [bashman_core](https://github.com/Blobfolio/bashman) | 0.5.1 | [Josh Stoik](mailto:[email protected]) | WTFPL |
1313
| [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 |
1414
| [cargo-platform](https://github.com/rust-lang/cargo) | 0.1.8 | | Apache-2.0 or MIT |
1515
| [cargo_metadata](https://github.com/oli-obk/cargo_metadata) | 0.18.1 | [Oliver Schneider](mailto:[email protected]) | MIT |
@@ -19,7 +19,7 @@
1919
| [displaydoc](https://github.com/yaahc/displaydoc) | 0.2.5 | [Jane Lusby](mailto:[email protected]) | Apache-2.0 or MIT |
2020
| [equivalent](https://github.com/cuviper/equivalent) | 1.0.1 | | Apache-2.0 or MIT |
2121
| [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 |
22-
| [fyi_msg](https://github.com/Blobfolio/fyi) | 0.14.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
22+
| [fyi_msg](https://github.com/Blobfolio/fyi) | 1.1.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
2323
| [hashbrown](https://github.com/rust-lang/hashbrown) | 0.15.0 | [Amanieu d'Antras](mailto:[email protected]) | Apache-2.0 or MIT |
2424
| [icu_collections](https://github.com/unicode-org/icu4x) | 1.5.0 | The ICU4X Project Developers | Unicode-3.0 |
2525
| [icu_locid](https://github.com/unicode-org/icu4x) | 1.5.0 | The ICU4X Project Developers | Unicode-3.0 |
@@ -38,13 +38,13 @@
3838
| [memchr](https://github.com/BurntSushi/memchr) | 2.7.4 | [Andrew Gallant](mailto:[email protected]) and bluss | MIT or Unlicense |
3939
| [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 |
4040
| [oxford_join](https://github.com/Blobfolio/oxford_join) | 0.4.0 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
41-
| [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 |
41+
| [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 |
4242
| [quote](https://github.com/dtolnay/quote) | 1.0.37 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
4343
| [ryu](https://github.com/dtolnay/ryu) | 1.0.18 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or BSL-1.0 |
4444
| [semver](https://github.com/dtolnay/semver) | 1.0.23 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
4545
| [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 |
4646
| [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 |
47-
| [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 |
47+
| [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 |
4848
| [serde_spanned](https://github.com/toml-rs/toml) | 0.6.8 | | Apache-2.0 or MIT |
4949
| [smallvec](https://github.com/servo/rust-smallvec) | 1.13.2 | The Servo Project Developers | Apache-2.0 or MIT |
5050
| [stable_deref_trait](https://github.com/storyyeller/stable_deref_trait) | 1.2.0 | [Robert Grosse](mailto:[email protected]) | Apache-2.0 or MIT |

bashman/Cargo.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cargo-bashman"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
license = "WTFPL"
55
authors = ["Josh Stoik <[email protected]>"]
66
edition = "2021"
@@ -64,9 +64,12 @@ description = "Path to the Cargo.toml file to use."
6464
label = "<Cargo.toml>"
6565
path = true
6666

67+
[build-dependencies]
68+
argyle = "0.10.*"
69+
6770
[dependencies]
68-
argyle = "0.8.*"
69-
fyi_msg = "0.14.*"
71+
argyle = "0.10.*"
72+
fyi_msg = "1.1.*"
7073

7174
[dependencies.bashman_core]
7275
path = "../bashman_core"

bashman/build.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*!
2+
# Cargo Bashman: Build
3+
*/
4+
5+
use argyle::KeyWordsBuilder;
6+
use std::path::PathBuf;
7+
8+
9+
10+
/// # Set Up CLI Arguments.
11+
pub fn main() {
12+
let mut builder = KeyWordsBuilder::default();
13+
builder.push_keys([
14+
"-h", "--help",
15+
"--no-bash",
16+
"--no-credits",
17+
"--no-man",
18+
"-V", "--version",
19+
]);
20+
builder.push_keys_with_values([
21+
"-f", "--features",
22+
"-m", "--manifest-path",
23+
]);
24+
builder.save(out_path("argyle.rs"));
25+
}
26+
27+
/// # Output Path.
28+
///
29+
/// Append the sub-path to OUT_DIR and return it.
30+
fn out_path(stub: &str) -> PathBuf {
31+
std::fs::canonicalize(std::env::var("OUT_DIR").expect("Missing OUT_DIR."))
32+
.expect("Missing OUT_DIR.")
33+
.join(stub)
34+
}

bashman/src/main.rs

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,7 @@
5353

5454

5555

56-
use argyle::{
57-
Argue,
58-
ArgyleError,
59-
FLAG_HELP,
60-
FLAG_VERSION,
61-
};
56+
use argyle::Argument;
6257
use bashman_core::{
6358
BashManError,
6459
FLAG_ALL,
@@ -75,10 +70,10 @@ use std::path::PathBuf;
7570
fn main() {
7671
match _main() {
7772
Ok(()) => {},
78-
Err(BashManError::Argue(ArgyleError::WantsVersion)) => {
73+
Err(BashManError::PrintVersion) => {
7974
println!(concat!("Cargo BashMan v", env!("CARGO_PKG_VERSION")));
8075
},
81-
Err(BashManError::Argue(ArgyleError::WantsHelp)) => { helper(); },
76+
Err(BashManError::PrintHelp) => { helper(); },
8277
Err(e) => { Msg::error(e.to_string()).die(1); },
8378
}
8479
}
@@ -87,41 +82,41 @@ fn main() {
8782
/// # Actual main.
8883
fn _main() -> Result<(), BashManError> {
8984
// Parse CLI arguments.
90-
let args = Argue::new(FLAG_HELP | FLAG_VERSION).map_err(BashManError::Argue)?;
91-
92-
// Check for invalid CLI options.
93-
if let Some(boo) = args.check_keys(
94-
&[b"--no-bash", b"--no-credits", b"--no-man"],
95-
&[b"--features", b"--manifest-path", b"-f", b"-m"],
96-
) {
97-
return Err(BashManError::InvalidCli(String::from_utf8_lossy(boo).into()));
98-
}
85+
let args = argyle::args()
86+
.with_keywords(include!(concat!(env!("OUT_DIR"), "/argyle.rs")));
9987

10088
let mut flags: u8 = FLAG_ALL;
101-
if args.switch(b"--no-bash") {
102-
flags &= ! FLAG_BASH;
103-
}
104-
if args.switch(b"--no-credits") {
105-
flags &= ! FLAG_CREDITS;
106-
}
107-
if args.switch(b"--no-man") {
108-
flags &= ! FLAG_MAN;
109-
}
110-
111-
let features = args.option2(b"-f", b"--features").and_then(|x| std::str::from_utf8(x).ok());
112-
113-
let manifest =
114-
if let Some(p) = args.option2_os(b"-m", b"--manifest-path") {
115-
PathBuf::from(p)
89+
let mut features = None;
90+
let mut manifest = None;
91+
for arg in args {
92+
match arg {
93+
Argument::Key("--no-bash") => { flags &= ! FLAG_BASH; },
94+
Argument::Key("--no-credits") => { flags &= ! FLAG_CREDITS; },
95+
Argument::Key("--no-man") => { flags &= ! FLAG_MAN; },
96+
97+
Argument::Key("-h" | "--help") => return Err(BashManError::PrintHelp),
98+
Argument::Key("-V" | "--version") => return Err(BashManError::PrintVersion),
99+
100+
Argument::KeyWithValue("-f" | "--features", s) => { features.replace(s); }
101+
Argument::KeyWithValue("-m" | "--manifest-path", s) => {
102+
manifest.replace(PathBuf::from(s));
103+
},
104+
105+
// Nothing else is expected.
106+
Argument::Other(s) => return Err(BashManError::InvalidCli(s.into_boxed_str())),
107+
Argument::InvalidUtf8(s) => return Err(BashManError::InvalidCli(s.to_string_lossy().into_owned().into_boxed_str())),
108+
_ => {},
116109
}
117-
else {
118-
std::env::current_dir()
119-
.map_err(|_| BashManError::InvalidManifest)?
120-
.join("Cargo.toml")
121-
};
110+
}
122111

123-
bashman_core::parse(manifest, flags, features)?;
112+
let manifest = match manifest {
113+
Some(m) => m,
114+
None => std::env::current_dir()
115+
.map_err(|_| BashManError::InvalidManifest)?
116+
.join("Cargo.toml"),
117+
};
124118

119+
bashman_core::parse(manifest, flags, features.as_deref())?;
125120
Ok(())
126121
}
127122

bashman_core/Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bashman_core"
3-
version = "0.5.0"
3+
version = "0.5.1"
44
license = "WTFPL"
55
authors = ["Josh Stoik <[email protected]>"]
66
edition = "2021"
@@ -10,11 +10,9 @@ publish = false
1010

1111
[dependencies]
1212
adbyss_psl = "0.13.*"
13-
argyle = "0.8.*"
1413
cargo_metadata = "=0.18.1"
1514
flate2 = "1.0.*"
16-
fyi_msg = "0.14.*"
17-
indexmap = "2.6.*"
15+
fyi_msg = "1.1.*"
1816
oxford_join = "0.4.*"
1917
trimothy = "0.3.*"
2018
utc2k = "0.10.*"

bashman_core/src/error.rs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,74 @@
22
# `Cargo BashMan` - Error
33
*/
44

5-
use argyle::ArgyleError;
65
use std::error::Error;
76
use std::fmt;
87

98

109

11-
#[derive(Debug, Clone)]
10+
#[derive(Debug, Clone, Eq, PartialEq)]
1211
/// # Error.
1312
pub enum BashManError {
14-
/// # Argue Passthru.
15-
Argue(ArgyleError),
1613
/// # Invalid Bash output directory.
1714
InvalidBashDir,
15+
1816
/// # Invalid Credits output directory.
1917
InvalidCreditsDir,
18+
2019
/// # Invalid CLI Option.
2120
InvalidCli(Box<str>),
21+
2222
/// # Invalid flag.
2323
InvalidFlag,
24+
2425
/// # Invalid item.
2526
InvalidItem,
27+
2628
/// # Invalid/missing Cargo.lock.
2729
InvalidLock,
30+
2831
/// # Invalid Man output directory.
2932
InvalidManDir,
33+
3034
/// # Invalid manifest.
3135
InvalidManifest,
36+
3237
/// # Invalid section.
3338
InvalidSection,
39+
3440
/// # Invalid subcommand.
3541
InvalidSubCommand(Box<str>),
42+
3643
/// # Missing subcommand.
3744
MissingSubCommand,
45+
3846
/// # Parse manifest.
3947
ParseManifest(Box<str>),
48+
4049
/// # Write Bash.
4150
WriteBash,
51+
4252
/// # Write Credits.
4353
WriteCredits,
54+
4455
/// # Write Man.
4556
WriteMan,
57+
4658
/// # Write Man.
4759
WriteSubMan(Box<str>),
60+
61+
/// # Print Help (Not an Error).
62+
PrintHelp,
63+
64+
/// # Print Version (Not an Error).
65+
PrintVersion,
4866
}
4967

5068
impl Error for BashManError {}
5169

5270
impl fmt::Display for BashManError {
5371
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5472
match self {
55-
Self::Argue(src) => f.write_str(src.as_str()),
5673
Self::InvalidBashDir => f.write_str("Invalid BASH output directory."),
5774
Self::InvalidCli(s) => f.write_fmt(format_args!("Invalid/unknown CLI option: {s}")),
5875
Self::InvalidCreditsDir => f.write_str("Invalid credits output directory."),
@@ -69,6 +86,7 @@ impl fmt::Display for BashManError {
6986
Self::WriteCredits => f.write_str("Unable to write CREDITS.md."),
7087
Self::WriteMan => f.write_str("Unable to write Manual(s)."),
7188
Self::WriteSubMan(s) => f.write_fmt(format_args!("Unable to write Man for {s:?}.")),
89+
Self::PrintHelp | Self::PrintVersion => Ok(()),
7290
}
7391
}
7492
}

bashman_core/src/raw.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@ use crate::{
2424
DataOption,
2525
More,
2626
};
27-
use indexmap::IndexMap;
2827
use serde::{
2928
Deserialize,
3029
Deserializer,
3130
};
32-
use std::path::{
33-
Path,
34-
PathBuf,
31+
use std::{
32+
collections::BTreeMap,
33+
path::{
34+
Path,
35+
PathBuf,
36+
},
3537
};
3638
use trimothy::TrimMut;
3739

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

406-
let mut subcmds: IndexMap<&'_ str, (&'_ str, &'_ str, &'_ str, Vec::<DataKind<'_>>)> = src.package.metadata.subcommands.iter()
408+
let mut subcmds: BTreeMap<&'_ str, (&'_ str, &'_ str, &'_ str, Vec::<DataKind<'_>>)> = src.package.metadata.subcommands.iter()
407409
.map(|y|
408410
(
409411
y.cmd.as_str(),

release/man/cargo-bashman.1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
.TH "CARGO BASHMAN" "1" "October 2024" "cargo\-bashman v0.5.0" "User Commands"
1+
.TH "CARGO BASHMAN" "1" "October 2024" "cargo\-bashman v0.5.1" "User Commands"
22
.SH NAME
3-
CARGO BASHMAN \- Manual page for cargo\-bashman v0.5.0.
3+
CARGO BASHMAN \- Manual page for cargo\-bashman v0.5.1.
44
.SH DESCRIPTION
55
A Cargo plugin to generate BASH completions and MAN pages.
66
.SS USAGE:

0 commit comments

Comments
 (0)