-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate the man page via clap_mangen
- Loading branch information
1 parent
a7b9f90
commit b8e0be2
Showing
6 changed files
with
78 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use std::env::var_os; | ||
use std::fs::write; | ||
use std::io::{ErrorKind, Result}; | ||
use std::path::PathBuf; | ||
|
||
// This is a bit of a hack to not have to rewrite the cli in the build | ||
#[path = "src/cli.rs"] | ||
mod cli; | ||
|
||
fn main() -> Result<()> { | ||
println!("cargo:rerun-if-changed=build.rs"); | ||
println!("cargo:rerun-if-changed=src/cli.rs"); | ||
|
||
let out_dir = PathBuf::from(var_os("OUT_DIR").ok_or(ErrorKind::NotFound)?); | ||
println!( | ||
"cargo:warning=manpages built at {:?}", | ||
out_dir.join("little_boxes.1") | ||
); | ||
|
||
let cmd = cli::cli(); | ||
|
||
let man = clap_mangen::Man::new(cmd); | ||
let mut buffer: Vec<u8> = Default::default(); | ||
man.render(&mut buffer)?; | ||
|
||
write(out_dir.join("little_boxes.1"), buffer)?; | ||
|
||
Ok(()) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,36 @@ | ||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.48.5. | ||
.TH LITTLE_BOXES "1" "November 2021" "little_boxes 1.7.0" "User Commands" | ||
.ie \n(.g .ds Aq \(aq | ||
.el .ds Aq ' | ||
.TH little_boxes 1 "little_boxes 1.7.0" | ||
.SH NAME | ||
little_boxes \- Adds boxes around stdin. Optionally adds a title. | ||
little_boxes \- Adds boxes around stdin. Optionally adds a title | ||
.SH SYNOPSIS | ||
\fBlittle_boxes\fR [\fB\-t\fR|\fB\-\-title\fR] [\fB\-c\fR|\fB\-\-charset\fR] [\fB\-f\fR|\fB\-\-file\fR] [\fB\-\-all\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] | ||
.SH DESCRIPTION | ||
little_boxes 1.7.0 | ||
Gio d'Amelio <[email protected]> | ||
Adds boxes around stdin. Optionally adds a title | ||
.SS "USAGE:" | ||
.IP | ||
little_boxes [FLAGS] [OPTIONS] | ||
.SS "FLAGS:" | ||
.SH OPTIONS | ||
.TP | ||
\fB\-t\fR, \fB\-\-title\fR=\fITITLE\fR | ||
Add a title to the box | ||
.TP | ||
\fB\-c\fR, \fB\-\-charset\fR=\fICHARSET\fR [default: thick] | ||
The charset to draw the box with | ||
.br | ||
|
||
.br | ||
[\fIpossible values: \fRthick, thin, double, box, rounded, dot] | ||
.TP | ||
\fB\-f\fR, \fB\-\-file\fR=\fIFILE\fR | ||
Read input from a file instead of stdin | ||
.TP | ||
\fB\-\-all\fR | ||
Compare all charsets | ||
.TP | ||
\fB\-h\fR, \fB\-\-help\fR | ||
Prints help information | ||
Print help | ||
.TP | ||
\fB\-V\fR, \fB\-\-version\fR | ||
Prints version information | ||
.SS "OPTIONS:" | ||
.TP | ||
\fB\-c\fR, \fB\-\-charset\fR <charset> | ||
The charset to draw the box with [default: thick] | ||
[possible values: thick, thin, double, box, | ||
rounded, dot] | ||
.TP | ||
\fB\-t\fR, \fB\-\-title\fR <title> | ||
Add a title to the box | ||
Print version | ||
.SH VERSION | ||
v1.7.0 | ||
.SH AUTHORS | ||
Gio d\*(AqAmelio <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use std::path::PathBuf; | ||
|
||
use clap::{arg, command, value_parser, Command}; | ||
|
||
pub fn cli() -> Command { | ||
command!() | ||
.arg(arg!(-t --title <TITLE> "Add a title to the box").required(false)) | ||
.arg( | ||
arg!(-c --charset <CHARSET> "The charset to draw the box with") | ||
.value_parser(["thick", "thin", "double", "box", "rounded", "dot"]) | ||
.default_value("thick"), | ||
) | ||
.arg( | ||
arg!(-f --file <FILE> "Read input from a file instead of stdin") | ||
.value_parser(value_parser!(PathBuf)), | ||
) | ||
.arg(arg!(--all "Compare all charsets")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters