Skip to content

Commit 6f3d54a

Browse files
committed
release: 0.3.4
2 parents 97e177c + 0700983 commit 6f3d54a

File tree

9 files changed

+31
-247
lines changed

9 files changed

+31
-247
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
release/completions/* linguist-detectable=false
2+
release/man/* linguist-detectable=false
3+
skel/* linguist-detectable=false

CREDITS.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# Project Dependencies
22
Package: cargo-bashman
3-
Version: 0.3.3
4-
Generated: 2022-01-21 04:29:00 UTC
3+
Version: 0.3.4
4+
Generated: 2022-01-30 20:48:09 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 |
99
| [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.3 | [Josh Stoik](mailto:[email protected]) | WTFPL |
10+
| [bashman_core](https://github.com/Blobfolio/bashman) | 0.3.4 | [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.1 | [Oliver Schneider](mailto:[email protected]) | MIT |
14-
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.2.3 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
15-
| [fyi_msg](https://github.com/Blobfolio/fyi) | 0.9.2 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
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 |
1616
| [hashbrown](https://github.com/rust-lang/hashbrown) | 0.11.2 | [Amanieu d'Antras](mailto:[email protected]) | Apache-2.0 or MIT |
1717
| [indexmap](https://github.com/bluss/indexmap) | 1.8.0 | 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 |
@@ -23,14 +23,14 @@
2323
| [once_cell](https://github.com/matklad/once_cell) | 1.9.0 | [Aleksey Kladov](mailto:[email protected]) | Apache-2.0 or MIT |
2424
| [oxford_join](https://github.com/Blobfolio/oxford_join) | 0.2.1 | [Blobfolio, LLC.](mailto:[email protected]) | WTFPL |
2525
| [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.14 | [David Tolnay](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 |
2727
| [regex](https://github.com/rust-lang/regex) | 1.5.4 | 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 |
3030
| [semver](https://github.com/dtolnay/semver) | 1.0.4 | [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
31-
| [serde](https://github.com/serde-rs/serde) | 1.0.133 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
32-
| [serde_derive](https://github.com/serde-rs/serde) | 1.0.133 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
33-
| [serde_json](https://github.com/serde-rs/json) | 1.0.75 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
31+
| [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 |
32+
| [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 |
33+
| [serde_json](https://github.com/serde-rs/json) | 1.0.78 | [Erick Tryzelaar](mailto:[email protected]) and [David Tolnay](mailto:[email protected]) | Apache-2.0 or MIT |
3434
| [syn](https://github.com/dtolnay/syn) | 1.0.86 | [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 |
3636
| [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 |

bashman/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cargo-bashman"
3-
version = "0.3.3"
3+
version = "0.3.4"
44
license = "WTFPL"
55
authors = ["Josh Stoik <[email protected]>"]
66
edition = "2021"
@@ -11,7 +11,7 @@ publish = false
1111

1212
[package.metadata.deb]
1313
maintainer = "Josh Stoik <[email protected]>"
14-
copyright = "2021, Blobfolio, LLC <[email protected]>"
14+
copyright = "2022, Blobfolio, LLC <[email protected]>"
1515
license-file = ["../LICENSE", "0"]
1616
revision = "1"
1717
depends = "$auto"

bashman/src/main.rs

Lines changed: 0 additions & 228 deletions
Original file line numberDiff line numberDiff line change
@@ -1,233 +1,5 @@
11
/*!
22
# `Cargo BashMan`
3-
4-
`BashMan` is a Cargo plugin that helps you generate BASH completions and/or MAN pages for your Rust apps using metadata from your projects' `Cargo.toml` manifests. It pairs well with the (unaffiliated) [cargo-deb](https://github.com/mmstick/cargo-deb).
5-
6-
BASH completions are sub-command aware — one level deep — and avoid making duplicate suggestions. For example, if the line already has `-h`, it will not suggest `-h` or its long variant `--help`.
7-
8-
MAN pages are automatically populated with the primary sections — `NAME`, `DESCRIPTION`, `USAGE`, `SUBCOMMANDS`, `FLAGS`, `OPTIONS`, `ARGUMENTS` — and the top level page can be extended with additional arbitrary sections as needed. If subcommands are defined, additional pages for each are generated, showing their particular usage, flags, etc.
9-
10-
MAN pages are saved in both plain ("app.1") and Gzipped ("app.1.gz") states. Linux `man` can read either format, so just pick whichever you prefer for distribution purposes. (Though Gzip is smaller…)
11-
12-
**This software is a work-in-progress.**
13-
14-
Feel free to use it, but if something weird happens — or if you have ideas for improvement — please open an [issue](https://github.com/Blobfolio/bashman/issues)!
15-
16-
17-
18-
## Installation
19-
20-
This application is written in [Rust](https://www.rust-lang.org/) and can be installed using [Cargo](https://github.com/rust-lang/cargo).
21-
22-
For stable Rust (>= `1.51.0`), run:
23-
```bash
24-
RUSTFLAGS="-C link-arg=-s" cargo install \
25-
--git https://github.com/Blobfolio/bashman.git \
26-
--bin cargo-bashman \
27-
--target x86_64-unknown-linux-gnu
28-
```
29-
30-
Pre-built `.deb` packages are also added for each [release](https://github.com/Blobfolio/bashman/releases/latest). They should always work for the latest stable Debian and Ubuntu.
31-
32-
33-
34-
## Usage
35-
36-
`BashMan` pulls all the data it needs to compile BASH completions and MAN pages straight from the specified `Cargo.toml` file. Once your manifest is set, all you need to do is run:
37-
38-
```bash
39-
cargo bashman [-m/--manifest-path] /path/to/Cargo.toml
40-
```
41-
42-
43-
## CONFIGURATION
44-
45-
The binary name, version, and description are taken from the standard `Cargo.toml` fields.
46-
47-
For everything else, start by adding a section to your `Cargo.toml` manifest like:
48-
49-
```toml
50-
[package.metadata.bashman]
51-
name = "Cargo BashMan"
52-
bash-dir = "../release/bash_completion.d"
53-
man-dir = "../release/man1"
54-
credits-dir = "../"
55-
```
56-
57-
| Key | Type | Description | Default |
58-
| --- | ---- | ----------- | ------- |
59-
| name | *string* | The proper name of your application. | If not provided, the binary name is used. |
60-
| bash-dir | *directory* | The output directory for BASH completions. This can be an absolute path, or a path relative to the manifest. | If not provided, the manifest's parent directory is used. |
61-
| credits-dir | *directory* | The output directory for the `CREDITS.md` dependency list. This can be an absolute path, or a path relative to the manifest. | If not provided, the manifest's parent directory is used. |
62-
| man-dir | *directory* | The output directory for MAN page(s). This can be an absolute path, or a path relative to the manifest. | If not provided, the manifest's parent directory is used. |
63-
| subcommands | *array* | An array of your app's subcommands, if any. | |
64-
| switches | *array* | An array of your app's true/false flags, if any. | |
65-
| options | *array* | An array of your app's key=value options, if any. | |
66-
| arguments | *array* | An array of any trailing arguments expected by your app. | |
67-
| sections | *array* | Arbitrary sections to append to the MAN page. | |
68-
69-
### SUBCOMMANDS
70-
71-
When adding subcommands, each entry requires the following fields:
72-
73-
| Key | Type | Description | Default |
74-
| --- | ---- | ----------- | ------- |
75-
| name | *string* | The proper name of the command. | If not provided, the `cmd` value will be used. |
76-
| cmd | *string* | The subcommand. | |
77-
| description | *string* | A description of what the subcommand does. | |
78-
79-
Subcommands can have their own switches, options, arguments. These are specified in the `switches`, `options`, and `arguments` sections respectively. Keep reading…
80-
81-
Example:
82-
```toml
83-
[[package.metadata.bashman.subcommands]]
84-
name="Whale Talk"
85-
cmd="whale"
86-
description="Print an underwater message."
87-
```
88-
89-
### SWITCHES
90-
91-
A "switch" is a CLI flag that either is or isn't. It can be a short key, like `-h`, or a long key like `--help`, or both. The value is implicitly `true` if the flag is present, or `false` if not.
92-
93-
Switches have the following fields:
94-
95-
| Key | Type | Description |
96-
| --- | ---- | ----------- |
97-
| short | *string* | A short key, like `-h`. |
98-
| long | *string* | A long key, like `--help`. |
99-
| description | *string* | A description for the flag. |
100-
| subcommands | *array* | If this switch applies to one or more subcommands, list the commands here. If a switch applies to the top-level app, omit this field, or include an empty `""` entry in the array. |
101-
102-
Example:
103-
```toml
104-
[[package.metadata.bashman.switches]]
105-
short = "-V"
106-
long = "--version"
107-
description = "Print application version."
108-
109-
[[package.metadata.bashman.switches]]
110-
short = "-h"
111-
long = "--help"
112-
description = "Print help information."
113-
subcommands = [ "call", "text", "" ]
114-
```
115-
116-
### OPTIONS
117-
118-
An "option" is exactly like a "switch", except it takes a value. As such, they have a couple more fields:
119-
120-
| Key | Type | Description |
121-
| --- | ---- | ----------- |
122-
| short | *string* | A short key, like `-h`. |
123-
| long | *string* | A long key, like `--help`. |
124-
| description | *string* | A description for the flag. |
125-
| label | *string* | A placeholder label for the value bit, like `<FILE>`. |
126-
| path | *bool* | If `true`, the BASH completions will suggest files/directories as potential values. If `false`, no value suggestion will be hazarded. |
127-
| subcommands | *array* | If this option applies to one or more subcommands, list the commands here. If an option applies to the top-level app, omit this field, or include an empty `""` entry in the array. |
128-
129-
Example:
130-
```toml
131-
[[package.metadata.bashman.options]]
132-
short = "-m"
133-
long = "--manifest-path"
134-
description = "Path to the Cargo.toml file to use."
135-
label = "<Cargo.toml>"
136-
path = true
137-
138-
[[package.metadata.bashman.options]]
139-
short = "-c"
140-
long = "--color"
141-
description = "Use this foreground color."
142-
label = "<NUM>"
143-
subcommands = [ "print", "echo" ]
144-
```
145-
146-
### ARGUMENTS
147-
148-
A trailing argument is what comes after everything else.
149-
150-
| Key | Type | Description |
151-
| --- | ---- | ----------- |
152-
| label | *string* | A placeholder label for the value bit, like `<FILE(s)…>`. |
153-
| description | *string* | A description for the argument. |
154-
| subcommands | *array* | If this argument applies to one or more subcommands, list the commands here. If it applies to the top-level app, omit this field, or include an empty `""` entry in the array. |
155-
156-
Example:
157-
```toml
158-
[[package.metadata.bashman.arguments]]
159-
label = "<FILE(s)…>"
160-
description = "Files and directories to search."
161-
subcommands = [ "search" ]
162-
```
163-
164-
### SECTIONS
165-
166-
`BashMan` will automatically generate manual sections for:
167-
* `NAME`
168-
* `DESCRIPTION`
169-
* `USAGE`
170-
* `SUBCOMMANDS` (if any)
171-
* `FLAGS` (i.e. "switches", if any)
172-
* `OPTIONS` (if any)
173-
* `ARGUMENTS` (if any)
174-
175-
If you would like to include other information (for the top-level MAN page), such as a list of sister software repositories, you can do so by adding sections with the following fields:
176-
177-
| Key | Type | Description |
178-
| --- | ---- | ----------- |
179-
| name | *string* | The section name, e.g. `RECIPES`. |
180-
| inside | *bool* | If `true`, the section will be indented (like most sections are). |
181-
| lines | *array* | An array of paragraph lines (strings) to append. Line breaks are forced between entries, but you could jam everything into one string to just have it wrap. |
182-
| items | *array* | An array of key/value pairs to list in a manner similar to how arguments are presented. Each entry should be an array with exactly two string values, `[ "Label", "A description or whatever." ]` |
183-
184-
Generally speaking, you'll want either "lines" or "items" for a given section, but not both.
185-
186-
Example:
187-
```toml
188-
[[package.metadata.bashman.sections]]
189-
name = "FILE TYPES"
190-
inside = true
191-
lines = [
192-
"This program will search for files with the following extensions:",
193-
".foo; .bar; .img",
194-
]
195-
196-
[[package.metadata.bashman.sections]]
197-
name = "CREDITS"
198-
inside = true
199-
items = [
200-
["Bob", "https://bob.com"],
201-
["Alice", "https://github.com/Alice"],
202-
]
203-
```
204-
205-
### ALL TOGETHER NOW
206-
207-
Taking `BashMan` as an example, the `Cargo.toml` will end up containing something like:
208-
```toml
209-
[package.metadata.bashman]
210-
name = "Cargo BashMan"
211-
bash-dir = "../release/bash_completion.d"
212-
man-dir = "../release/man1"
213-
214-
[[package.metadata.bashman.switches]]
215-
short = "-h"
216-
long = "--help"
217-
description = "Print help information."
218-
219-
[[package.metadata.bashman.switches]]
220-
short = "-V"
221-
long = "--version"
222-
description = "Print application version."
223-
224-
[[package.metadata.bashman.options]]
225-
short = "-m"
226-
long = "--manifest-path"
227-
description = "Path to the Cargo.toml file to use."
228-
label = "<Cargo.toml>"
229-
path = true
230-
```
2313
*/
2324

2335
#![forbid(unsafe_code)]

bashman_core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bashman_core"
3-
version = "0.3.3"
3+
version = "0.3.4"
44
license = "WTFPL"
55
authors = ["Josh Stoik <[email protected]>"]
66
edition = "2021"

bashman_core/src/credits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub(super) fn get_dependencies(src: &Path) -> Result<Vec<Dependency>, BashManErr
9090
if out.insert(package_id) {
9191
stack.extend(deps[package_id].iter().filter_map(
9292
|NodeDep { pkg, dep_kinds, .. }|
93-
if dep_kinds.iter().any(|DepKindInfo { kind, .. }| *kind == DependencyKind::Normal) {
93+
if dep_kinds.iter().any(|DepKindInfo { kind, target, .. }| *kind == DependencyKind::Normal && target.is_none()) {
9494
Some(pkg)
9595
}
9696
else { None }

bashman_core/src/data.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,19 @@ impl<'a> Command<'a> {
134134
self.bash_subcommands(buf)?;
135135
}
136136

137+
// We might be able to compress the output a bit by removing contiguous
138+
// line breaks.
139+
{
140+
let mut last: u8 = b'?';
141+
buf.retain(|&b|
142+
if b == b'\n' && b == last { false }
143+
else {
144+
last = b;
145+
true
146+
}
147+
);
148+
}
149+
137150
// Write it to a file!
138151
let mut out_file = path.to_path_buf();
139152
out_file.push(self.bin.to_string() + ".bash");

release/completions/cargo-bashman.bash

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ _basher___cargo_bashman() {
44
cur="${COMP_WORDS[COMP_CWORD]}"
55
prev="${COMP_WORDS[COMP_CWORD-1]}"
66
opts=()
7-
87
if [[ ! " ${COMP_LINE} " =~ " -h " ]] && [[ ! " ${COMP_LINE} " =~ " --help " ]]; then
98
opts+=("-h")
109
opts+=("--help")
@@ -20,13 +19,11 @@ _basher___cargo_bashman() {
2019
opts+=("-m")
2120
opts+=("--manifest-path")
2221
fi
23-
2422
opts=" ${opts[@]} "
2523
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
2624
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
2725
return 0
2826
fi
29-
3027
case "${prev}" in
3128
-m|--manifest-path)
3229
if [ -z "$( declare -f _filedir )" ]; then
@@ -40,7 +37,6 @@ _basher___cargo_bashman() {
4037
COMPREPLY=()
4138
;;
4239
esac
43-
4440
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
4541
return 0
4642
}

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" "January 2022" "Cargo BashMan v0.3.3" "User Commands"
1+
.TH "CARGO BASHMAN" "1" "January 2022" "Cargo BashMan v0.3.4" "User Commands"
22
.SH NAME
3-
Cargo BashMan \- Manual page for cargo\-bashman v0.3.3.
3+
Cargo BashMan \- Manual page for cargo\-bashman v0.3.4.
44
.SH DESCRIPTION
55
BashMan is a Cargo plugin that helps you generate BASH completions and/or MAN pages for your Rust project.
66
.SS USAGE:

0 commit comments

Comments
 (0)