Skip to content

Commit 26a949a

Browse files
committed
release: 0.3.6
2 parents 5cd0b9d + 519fdef commit 26a949a

File tree

8 files changed

+120
-102
lines changed

8 files changed

+120
-102
lines changed

CREDITS.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
11
# Project Dependencies
22
Package: cargo-bashman
3-
Version: 0.3.5
4-
Generated: 2022-02-24 17:29:24 UTC
3+
Version: 0.3.6
4+
Generated: 2022-04-07 15:50:36 UTC
55

66
| Package | Version | Author(s) | License |
77
| ---- | ---- | ---- | ---- |
88
| [aho-corasick](https://github.com/BurntSushi/aho-corasick) | 0.7.18 | [Andrew Gallant](mailto:[email protected]) | MIT or Unlicense |
9-
| [argyle](https://github.com/Blobfolio/argyle) | 0.5.2 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
10-
| [bashman_core](https://github.com/Blobfolio/bashman) | 0.3.5 | [Josh Stoik](mailto:[email protected]) | WTFPL |
9+
| [argyle](https://github.com/Blobfolio/argyle) | 0.5.3 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
10+
| [bashman_core](https://github.com/Blobfolio/bashman) | 0.3.6 | [Josh Stoik](mailto:[email protected]) | WTFPL |
1111
| [camino](https://github.com/camino-rs/camino) | 1.0.7 | [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 |
1212
| [cargo-platform](https://github.com/rust-lang/cargo) | 0.1.2 | The Cargo Project Developers | Apache-2.0 or MIT |
1313
| [cargo_metadata](https://github.com/oli-obk/cargo_metadata) | 0.14.2 | [Oliver Schneider](mailto:[email protected]) | MIT |
14-
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.2.4 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
15-
| [fyi_msg](https://github.com/Blobfolio/fyi) | 0.9.3 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
14+
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.3.3 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
15+
| [fyi_msg](https://github.com/Blobfolio/fyi) | 0.9.7 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
1616
| [hashbrown](https://github.com/rust-lang/hashbrown) | 0.11.2 | [Amanieu d'Antras](mailto:[email protected]) | Apache-2.0 or MIT |
17-
| [indexmap](https://github.com/bluss/indexmap) | 1.8.0 | bluss and [Josh Stone](mailto:[email protected]) | Apache-2.0 or MIT |
17+
| [indexmap](https://github.com/bluss/indexmap) | 1.8.1 | bluss and [Josh Stone](mailto:[email protected]) | Apache-2.0 or MIT |
1818
| [itoa](https://github.com/dtolnay/itoa) | 1.0.1 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
19-
| [libdeflate-sys](https://github.com/adamkewley/libdeflater) | 0.7.5 | [Adam Kewley](mailto:[email protected]) | Apache-2.0 |
20-
| [libdeflater](https://github.com/adamkewley/libdeflater) | 0.7.5 | [Adam Kewley](mailto:[email protected]) | Apache-2.0 |
19+
| [libdeflate-sys](https://github.com/adamkewley/libdeflater) | 0.8.0 | [Adam Kewley](mailto:[email protected]) | Apache-2.0 |
20+
| [libdeflater](https://github.com/adamkewley/libdeflater) | 0.8.0 | [Adam Kewley](mailto:[email protected]) | Apache-2.0 |
2121
| [memchr](https://github.com/BurntSushi/memchr) | 2.4.1 | [Andrew Gallant](mailto:[email protected]) and bluss | MIT or Unlicense |
2222
| [num-traits](https://github.com/rust-num/num-traits) | 0.2.14 | The Rust Project Developers | Apache-2.0 or MIT |
23-
| [once_cell](https://github.com/matklad/once_cell) | 1.9.0 | [Aleksey Kladov](mailto:[email protected]) | Apache-2.0 or MIT |
24-
| [oxford_join](https://github.com/Blobfolio/oxford_join) | 0.2.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
25-
| [proc-macro2](https://github.com/dtolnay/proc-macro2) | 1.0.36 | [David Tolnay](mailto:[email protected]) and [Alex Crichton](mailto:[email protected]) | Apache-2.0 or MIT |
26-
| [quote](https://github.com/dtolnay/quote) | 1.0.15 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
27-
| [regex](https://github.com/rust-lang/regex) | 1.5.4 | The Rust Project Developers | Apache-2.0 or MIT |
23+
| [once_cell](https://github.com/matklad/once_cell) | 1.10.0 | [Aleksey Kladov](mailto:[email protected]) | Apache-2.0 or MIT |
24+
| [oxford_join](https://github.com/Blobfolio/oxford_join) | 0.2.2 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
25+
| [proc-macro2](https://github.com/dtolnay/proc-macro2) | 1.0.37 | [David Tolnay](mailto:[email protected]) and [Alex Crichton](mailto:[email protected]) | Apache-2.0 or MIT |
26+
| [quote](https://github.com/dtolnay/quote) | 1.0.17 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
27+
| [regex](https://github.com/rust-lang/regex) | 1.5.5 | The Rust Project Developers | Apache-2.0 or MIT |
2828
| [regex-syntax](https://github.com/rust-lang/regex) | 0.6.25 | The Rust Project Developers | Apache-2.0 or MIT |
2929
| [ryu](https://github.com/dtolnay/ryu) | 1.0.9 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or BSL-1.0 |
30-
| [semver](https://github.com/dtolnay/semver) | 1.0.6 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
30+
| [semver](https://github.com/dtolnay/semver) | 1.0.7 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
3131
| [serde](https://github.com/serde-rs/serde) | 1.0.136 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
3232
| [serde_derive](https://github.com/serde-rs/serde) | 1.0.136 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
3333
| [serde_json](https://github.com/serde-rs/json) | 1.0.79 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
34-
| [syn](https://github.com/dtolnay/syn) | 1.0.86 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
34+
| [syn](https://github.com/dtolnay/syn) | 1.0.91 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
3535
| [toml](https://github.com/alexcrichton/toml-rs) | 0.5.8 | [Alex Crichton](mailto:[email protected]) | Apache-2.0 or MIT |
36+
| [trim-in-place](https://github.com/magiclen/trim-in-place) | 0.1.7 | [Magic Len](mailto:[email protected]) | MIT |
3637
| [unicode-xid](https://github.com/unicode-rs/unicode-xid) | 0.2.2 | [erick.tryzelaar](mailto:[email protected]), [kwantam](mailto:[email protected]), and [Manish Goregaokar](mailto:[email protected]) | Apache-2.0 or MIT |
37-
| [utc2k](https://github.com/Blobfolio/utc2k) | 0.3.4 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
38+
| [utc2k](https://github.com/Blobfolio/utc2k) | 0.4.2 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[workspace]
2+
resolver = "2"
23
members = [
34
"bashman",
45
"bashman_core",
@@ -8,3 +9,4 @@ members = [
89
lto = true
910
codegen-units = 1
1011
opt-level = 3
12+
strip = true

bashman/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[package]
22
name = "cargo-bashman"
3-
version = "0.3.5"
3+
version = "0.3.6"
44
license = "WTFPL"
55
authors = ["Josh Stoik <[email protected]>"]
66
edition = "2021"
7-
rust-version = "1.56"
7+
rust-version = "1.59"
88
description = "A Cargo plugin to generate BASH completions and MAN pages."
99
repository = "https://github.com/Blobfolio/bashman"
1010
publish = false
@@ -59,7 +59,7 @@ label = "<Cargo.toml>"
5959
path = true
6060

6161
[dependencies]
62-
argyle = "0.5.*"
62+
argyle = "0.5.*, >=0.5.3"
6363
fyi_msg = "0.9.*"
6464

6565
[dependencies.bashman_core]

bashman/src/main.rs

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,21 @@
3232
#![allow(clippy::module_name_repetitions)]
3333

3434

35+
use argyle::{
36+
Argue,
37+
ArgyleError,
38+
FLAG_HELP,
39+
FLAG_VERSION,
40+
};
3541
use bashman_core::{
3642
BashManError,
3743
FLAG_ALL,
3844
FLAG_BASH,
3945
FLAG_CREDITS,
4046
FLAG_MAN,
4147
};
42-
use argyle::{
43-
Argue,
44-
ArgyleError,
45-
FLAG_HELP,
46-
FLAG_VERSION,
47-
};
4848
use fyi_msg::Msg;
49-
use std::{
50-
ffi::OsStr,
51-
os::unix::ffi::OsStrExt,
52-
path::PathBuf,
53-
};
49+
use std::path::PathBuf;
5450

5551

5652

@@ -87,18 +83,17 @@ fn _main() -> Result<(), BashManError> {
8783
flags &= ! FLAG_MAN;
8884
}
8985

90-
bashman_core::parse(
91-
args.option2(b"-m", b"--manifest-path")
92-
.map_or_else(
93-
|| std::env::current_dir().ok().map(|mut p| {
94-
p.push("Cargo.toml");
95-
p
96-
}),
97-
|b| Some(PathBuf::from(OsStr::from_bytes(b)))
98-
)
99-
.ok_or(BashManError::InvalidManifest)?,
100-
flags,
101-
)?;
86+
let manifest =
87+
if let Some(p) = args.option2_os(b"-m", b"--manifest-path") {
88+
PathBuf::from(p)
89+
}
90+
else {
91+
std::env::current_dir()
92+
.map_err(|_| BashManError::InvalidManifest)?
93+
.join("Cargo.toml")
94+
};
95+
96+
bashman_core::parse(manifest, flags)?;
10297

10398
Ok(())
10499
}

bashman_core/Cargo.toml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
[package]
22
name = "bashman_core"
3-
version = "0.3.5"
3+
version = "0.3.6"
44
license = "WTFPL"
55
authors = ["Josh Stoik <[email protected]>"]
66
edition = "2021"
7-
rust-version = "1.56"
7+
rust-version = "1.59"
88
description = "The backing library for Cargo Bashman."
99
repository = "https://github.com/Blobfolio/bashman"
1010
publish = false
1111

1212
[dependencies]
1313
argyle = "0.5.*"
14-
cargo_metadata = "0.14.*"
14+
cargo_metadata = "=0.14.2"
1515
fyi_msg = "0.9.*"
16-
indexmap = "1.8.*"
17-
libdeflater = "0.7.*"
18-
once_cell = "1.9.*"
16+
indexmap = "=1.8.1"
17+
libdeflater = "=0.8.0"
18+
once_cell = "=1.10.0"
1919
oxford_join = "0.2.*"
20-
regex = "1.5.*"
21-
utc2k = "0.3.*"
20+
regex = "=1.5.5"
21+
trim-in-place = "=0.1.7"
22+
utc2k = "0.4.*"
2223

2324
[dependencies.serde]
24-
version = "1.0.*"
25+
version = "=1.0.136"
2526
features = [ "derive" ]
2627

2728
[dependencies.toml]
28-
version = "0.5.*"
29+
version = "=0.5.8"
2930
features = [ "preserve_order" ]

bashman_core/src/credits.rs

Lines changed: 62 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ use once_cell::sync::Lazy;
1919
use oxford_join::OxfordJoin;
2020
use regex::Regex;
2121
use std::{
22+
cmp::Ordering,
2223
collections::{
2324
HashMap,
2425
HashSet,
2526
},
2627
path::Path,
2728
};
28-
29+
use trim_in_place::TrimInPlace;
2930

3031

3132

@@ -39,6 +40,8 @@ pub(super) struct Dependency {
3940
pub(super) link: Option<String>,
4041
}
4142

43+
impl Eq for Dependency {}
44+
4245
impl From<Package> for Dependency {
4346
fn from(mut src: Package) -> Self {
4447
strip_markdown(&mut src.name);
@@ -55,6 +58,21 @@ impl From<Package> for Dependency {
5558
}
5659
}
5760

61+
impl Ord for Dependency {
62+
#[inline]
63+
fn cmp(&self, other: &Self) -> Ordering { self.name.cmp(&other.name) }
64+
}
65+
66+
impl PartialEq for Dependency {
67+
#[inline]
68+
fn eq(&self, other: &Self) -> bool { self.name == other.name }
69+
}
70+
71+
impl PartialOrd for Dependency {
72+
#[inline]
73+
fn partial_cmp(&self, other: &Self) -> Option<Ordering> { Some(self.cmp(other)) }
74+
}
75+
5876

5977

6078
/// # Get Dependencies.
@@ -68,33 +86,32 @@ pub(super) fn get_dependencies(src: &Path) -> Result<Vec<Dependency>, BashManErr
6886
// Parse out all of the package IDs in the dependency tree, excluding dev-
6987
// and build-deps.
7088
let deps = {
71-
let resolve = metadata.resolve.as_ref()
72-
.ok_or(BashManError::InvalidManifest)?;
89+
let resolve = metadata.resolve.as_ref().ok_or(BashManError::InvalidManifest)?;
7390

7491
// Pull dependencies by package.
75-
let deps: HashMap<&PackageId, &Vec<NodeDep>> = resolve
76-
.nodes
77-
.iter()
78-
.map(|Node { id, deps, .. }| (id, deps))
92+
let deps: HashMap<&PackageId, &[NodeDep]> = resolve.nodes.iter()
93+
.map(|Node { id, deps, .. }| (id, deps.as_slice()))
7994
.collect();
8095

8196
// Build a list of all unique, normal dependencies.
8297
let mut out: HashSet<&PackageId> = HashSet::new();
83-
let stack = &mut resolve.root.as_ref()
98+
let mut stack: Vec<_> = resolve.root.as_ref()
8499
.map_or_else(
85100
|| metadata.workspace_members.iter().collect(),
86101
|root| vec![root]
87102
);
88103

89104
while let Some(package_id) = stack.pop() {
90105
if out.insert(package_id) {
91-
stack.extend(deps[package_id].iter().filter_map(
92-
|NodeDep { pkg, dep_kinds, .. }|
93-
if dep_kinds.iter().any(|DepKindInfo { kind, target, .. }| *kind == DependencyKind::Normal && target.is_none()) {
94-
Some(pkg)
106+
if let Some(d) = deps.get(package_id).copied() {
107+
if ! d.is_empty() {
108+
for NodeDep { pkg, dep_kinds, .. } in d {
109+
if dep_kinds.iter().any(|DepKindInfo { kind, target, .. }| target.is_none() && *kind == DependencyKind::Normal) {
110+
stack.push(pkg);
111+
}
112+
}
95113
}
96-
else { None }
97-
));
114+
}
98115
}
99116
}
100117

@@ -104,53 +121,57 @@ pub(super) fn get_dependencies(src: &Path) -> Result<Vec<Dependency>, BashManErr
104121
// One final time around to pull the relevant package details for each
105122
// corresponding ID.
106123
let mut out: Vec<Dependency> = metadata.packages.into_iter()
107-
.filter(|p| deps.contains(&p.id))
108-
.map(Dependency::from)
109-
.collect();
124+
.filter_map(|p|
125+
if deps.contains(&p.id) { Some(Dependency::from(p)) }
126+
else { None }
127+
)
128+
.collect();
110129

111-
out.sort_by(|a, b| a.name.to_ascii_lowercase().cmp(&b.name.to_ascii_lowercase()));
130+
out.sort_unstable();
112131

113132
Ok(out)
114133
}
115134

135+
136+
137+
/// # Normalize Authors.
138+
fn nice_author(mut raw: Vec<String>) -> String {
139+
static RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"(.+?) <([^>]+)>").unwrap());
140+
141+
for x in &mut raw {
142+
x.trim_in_place();
143+
x.retain(|c| ! matches!(c, '[' | ']' | '(' | ')' | '|'));
144+
145+
let y = RE.replace_all(x, "[$1](mailto:$2)");
146+
if *x != y {
147+
*x = y.into_owned();
148+
}
149+
}
150+
151+
raw.oxford_and().into_owned()
152+
}
153+
116154
/// # Normalize Licenses.
117155
fn nice_license(raw: &str) -> String {
118156
let mut raw = raw.replace(" OR ", "/");
119-
strip_markdown(&mut raw);
157+
raw.retain(|c| ! matches!(c, '[' | ']' | '<' | '>' | '(' | ')' | '|'));
158+
120159
let mut list: Vec<&str> = raw.split('/').map(str::trim).collect();
121160
list.sort_unstable();
122161
list.dedup();
123162
list.oxford_or().into_owned()
124163
}
125164

126-
/// # Normalize Authors.
127-
fn nice_author(raw: Vec<String>) -> String {
128-
static RE1: Lazy<Regex> = Lazy::new(|| Regex::new(r"(\[|\]|\||\(|\))").unwrap());
129-
static RE2: Lazy<Regex> = Lazy::new(|| Regex::new(r"(.+?) <([^>]+)>").unwrap());
130-
131-
let list: Vec<String> = raw.into_iter()
132-
.map(|x| {
133-
let y = RE1.replace_all(&x, "");
134-
let z = RE2.replace_all(y.trim(), "[$1](mailto:$2)");
135-
if x == z { x }
136-
else { z.into_owned() }
137-
})
138-
.collect();
139-
list.oxford_and().into_owned()
140-
}
141-
142165
/// # Lightly Sanitize.
143166
///
144167
/// Remove `[] <> () |` to help with later markdown display.
145168
fn strip_markdown(raw: &mut String) {
146-
static RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"(\[|\]|\||<|>|\(|\))").unwrap());
147-
148-
let alt = RE.replace_all(raw.trim(), "");
149-
if raw != &alt {
150-
*raw = alt.into_owned();
151-
}
169+
raw.trim_in_place();
170+
raw.retain(|c| ! matches!(c, '[' | ']' | '<' | '>' | '(' | ')' | '|'));
152171
}
153172

173+
174+
154175
#[cfg(test)]
155176
mod tests {
156177
use super::*;

0 commit comments

Comments
 (0)