Skip to content

Commit c15ecc7

Browse files
committed
release: 0.6.3
2 parents fa25a54 + e44c80b commit c15ecc7

File tree

15 files changed

+1426
-1420
lines changed

15 files changed

+1426
-1420
lines changed

CREDITS.md

Lines changed: 71 additions & 79 deletions
Large diffs are not rendered by default.

Cargo.toml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cargo-bashman"
3-
version = "0.6.2"
3+
version = "0.6.3"
44
license = "WTFPL"
55
authors = ["Josh Stoik <[email protected]>"]
66
edition = "2021"
@@ -75,7 +75,6 @@ adbyss_psl = "0.14.*"
7575
dactyl = "0.7.4"
7676
fyi_msg = "1.1.*"
7777
oxford_join = "0.4.*"
78-
serde_json = "1.0.*"
7978
trimothy = "0.3.*"
8079
utc2k = "0.11.*"
8180
write_atomic = "0.5.*"
@@ -92,9 +91,9 @@ features = [ "serde" ]
9291
version = "1.0.*"
9392
features = [ "derive" ]
9493

95-
[dependencies.toml]
96-
version = "0.8.*"
97-
features = [ "preserve_order" ]
94+
[dependencies.serde_json]
95+
version = "1.0.*"
96+
features = [ "raw_value" ]
9897

9998
[dependencies.url]
10099
version = "2.5.*"

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ MAN pages are saved in both plain ("app.1") and GZipped ("app.1.gz") states. Lin
1717

1818
## Installation
1919

20+
As might be expected, `cargo bashman` requires [`cargo`](https://github.com/rust-lang/cargo). If you don't already have that installed, check out [rustup](https://rustup.rs/) before continuing.
21+
2022
Debian and Ubuntu users can just grab the pre-built `.deb` package from the [latest release](https://github.com/Blobfolio/bashman/releases/latest).
2123

22-
This application is written in [Rust](https://www.rust-lang.org/) and can alternatively be built from source using [Cargo](https://github.com/rust-lang/cargo):
24+
To build from source:
2325

2426
```bash
2527
# Clone the source.
@@ -30,7 +32,7 @@ cd bashman
3032

3133
# Build as usual. Specify additional flags as desired.
3234
cargo build \
33-
--bin bashman \
35+
--bin cargo-bashman \
3436
--release
3537
```
3638

@@ -52,8 +54,6 @@ cargo bashman [-h/--help]
5254

5355
The flags `--no-bash`, `--no-man`, and `--no-credits` can be used to skip the generation of BASH completions, MAN pages, and/or `CREDITS.md` respectively.
5456

55-
Note that for the `CREDITS.md` feature, [Cargo](https://github.com/rust-lang/cargo) is explicitly required. (It pulls the dependency tree from the `cargo metadata` output.)
56-
5757

5858
## CONFIGURATION
5959

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" "November 2024" "cargo\-bashman v0.6.2" "User Commands"
1+
.TH "CARGO BASHMAN" "1" "November 2024" "cargo\-bashman v0.6.3" "User Commands"
22
.SH NAME
3-
CARGO BASHMAN \- Manual page for cargo\-bashman v0.6.2.
3+
CARGO BASHMAN \- Manual page for cargo\-bashman v0.6.3.
44
.SH DESCRIPTION
55
A Cargo plugin to generate bash completions, man pages, and/or crate credits.
66
.SS USAGE:

src/bash.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -535,23 +535,3 @@ impl<'a> Subcommand<'a> {
535535
out
536536
}
537537
}
538-
539-
540-
541-
#[cfg(test)]
542-
mod test {
543-
use super::*;
544-
545-
#[test]
546-
fn t_bash() {
547-
let manifest = Manifest::from_file("skel/test.toml")
548-
.expect("Manifest parsing failed.");
549-
let writer = BashWriter::try_from(&manifest)
550-
.expect("Man set up failed.");
551-
552-
assert_eq!(
553-
writer.to_string().replace("\n\n", "\n"),
554-
include_str!("../skel/test.bash"),
555-
);
556-
}
557-
}

src/credits.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub(super) struct CreditsWriter<'a> {
4444
target: Option<TargetTriple>,
4545

4646
/// # Dependencies.
47-
dependencies: Vec<Dependency>,
47+
dependencies: &'a [Dependency],
4848
}
4949

5050
impl<'a> fmt::Display for CreditsWriter<'a> {
@@ -83,28 +83,27 @@ impl<'a> fmt::Display for CreditsWriter<'a> {
8383
}
8484

8585
// There may not be any dependencies.
86-
let deps = self.dependencies.as_slice();
87-
if deps.is_empty() {
86+
if self.dependencies.is_empty() {
8887
return f.write_str("This project has no dependencies.\n");
8988
}
9089

9190
// Some dependencies are context dependent; some work is required.
92-
if deps.iter().any(Dependency::conditional) {
91+
if self.dependencies.iter().any(Dependency::conditional) {
9392
f.write_str("| Package | Version | Author(s) | License | Context |\n| ---- | ---- | ---- | ---- | ---- |\n")?;
9493

9594
// Required first.
96-
for dep in deps {
95+
for dep in self.dependencies {
9796
if ! dep.conditional() { writeln!(f, "{dep} |")?; }
9897
}
9998
// Now the specific ones.
100-
for dep in deps {
99+
for dep in self.dependencies {
101100
if dep.conditional() { writeln!(f, "{dep} {} |", dep.context())?; }
102101
}
103102
}
104103
// Everything is needed all the time!
105104
else {
106105
f.write_str("| Package | Version | Author(s) | License |\n| ---- | ---- | ---- | ---- |\n")?;
107-
for dep in deps { writeln!(f, "{dep}")?; }
106+
for dep in self.dependencies { writeln!(f, "{dep}")?; }
108107
}
109108

110109
Ok(())
@@ -113,22 +112,21 @@ impl<'a> fmt::Display for CreditsWriter<'a> {
113112

114113
impl<'a> CreditsWriter<'a> {
115114
/// # New Instance.
116-
pub(super) fn new(man: &'a Manifest, target: Option<TargetTriple>)
115+
pub(super) fn new(man: &'a Manifest)
117116
-> Result<Self, BashManError> {
118117
let src = man.src();
119118
let dst = man.dir_credits()?.join("CREDITS.md");
120119
let cmd = man.main_cmd().ok_or(BashManError::Credits)?;
121120
let name = cmd.bin();
122-
let dependencies = man.dependencies(target)?;
123121

124122
// Done!
125123
Ok(Self {
126124
src,
127125
dst,
128126
name,
129127
version: cmd.version(),
130-
target,
131-
dependencies,
128+
target: man.target(),
129+
dependencies: man.dependencies(),
132130
})
133131
}
134132

src/err.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ pub(super) enum BashManError {
8787
/// # Cargo Metadata (JSON) Parsing Error.
8888
ParseCargoMetadata(String),
8989

90-
/// # Cargo.toml Parsing Error.
91-
ParseToml(String),
92-
9390
/// # Read Error.
9491
Read(String),
9592

@@ -140,7 +137,6 @@ impl fmt::Display for BashManError {
140137
if s.is_empty() { "Package name cannot be empty." }
141138
else { return write!(f, "Invalid package name: {s}"); },
142139
Self::ParseCargoMetadata(s) => return write!(f, "Cargo metadata parsing error: {s}"),
143-
Self::ParseToml(s) => return write!(f, "Cargo.toml parsing error: {s}"),
144140
Self::Read(s) => return write!(f, "Unable to read: {s}"),
145141
Self::UnknownCommand(s) => return write!(f, "Unknown (sub)command: {s}"),
146142
Self::Write(s) => return write!(f, "Unable to write: {s}"),

src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ fn _main() -> Result<(), BashManError> {
198198
None => CWD.as_ref()
199199
.ok_or_else(|| BashManError::Dir("working", "./".to_owned()))?
200200
.join("Cargo.toml"),
201-
})?;
201+
}, target)?;
202202

203203
// Set up a shared buffer for whatever we'll be writing to help reduce
204204
// allocations.
@@ -235,7 +235,7 @@ fn _main() -> Result<(), BashManError> {
235235

236236
// Crate Credits.
237237
if FLAG_CREDITS == flags & FLAG_CREDITS {
238-
match CreditsWriter::new(&manifest, target).and_then(|w| w.write(&mut buf)) {
238+
match CreditsWriter::new(&manifest).and_then(|w| w.write(&mut buf)) {
239239
Ok(p) => {
240240
good.push("credits");
241241
files.push(p);

src/man.rs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -570,40 +570,3 @@ fn output_file(dir: &Path, parent_cmd: Option<&str>, cmd: &str) -> PathBuf {
570570
}
571571
)
572572
}
573-
574-
575-
576-
#[cfg(test)]
577-
mod test {
578-
use super::*;
579-
580-
#[test]
581-
fn t_man() {
582-
// The date bits will change.
583-
let now = Utc2k::now();
584-
let date = format!("{} {}", now.month_name(), now.year());
585-
586-
// The expected output.
587-
let expected = [
588-
std::fs::read_to_string("skel/test.1")
589-
.expect("Missing skel/test.1")
590-
.replace("VARIABLEDATE", date.as_str()),
591-
std::fs::read_to_string("skel/test-action.1")
592-
.expect("Missing skel/test-action.1")
593-
.replace("VARIABLEDATE", date.as_str()),
594-
std::fs::read_to_string("skel/test-make.1")
595-
.expect("Missing skel/test-make.1")
596-
.replace("VARIABLEDATE", date.as_str()),
597-
];
598-
599-
let manifest = Manifest::from_file("skel/test.toml")
600-
.expect("Manifest parsing failed.");
601-
let writer = ManWriter::try_from(&manifest)
602-
.expect("Man set up failed.");
603-
604-
assert_eq!(writer.men.len(), expected.len());
605-
for (idx, (a, b)) in writer.men.iter().zip(expected.iter()).enumerate() {
606-
assert_eq!(a.to_string(), b.as_str(), "Man page #{idx} differs.");
607-
}
608-
}
609-
}

0 commit comments

Comments
 (0)