Generate man page with help2man (#463)
The generated man page doesn't look great by default, so this also adds the help4help2man feature, which makes Just print a help message that produces a better man page.
This commit is contained in:
parent
74e45e7c05
commit
04a2b6461e
@ -8,6 +8,10 @@ homepage = "https://github.com/casey/just"
|
||||
readme = "crates-io-readme.md"
|
||||
edition = "2018"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
help4help2man = []
|
||||
|
||||
[dependencies]
|
||||
ansi_term = "0.11"
|
||||
assert_matches = "1"
|
||||
|
14
justfile
14
justfile
@ -36,6 +36,16 @@ check:
|
||||
watch +COMMAND='test':
|
||||
cargo watch --clear --exec "{{COMMAND}}"
|
||||
|
||||
man:
|
||||
cargo build --features help4help2man
|
||||
help2man \
|
||||
--name 'save and run commands' \
|
||||
--manual 'JUST MANUAL' \
|
||||
--no-info \
|
||||
target/debug/just \
|
||||
> man/just.1
|
||||
man man/just.1
|
||||
|
||||
version := `sed -En 's/version[[:space:]]*=[[:space:]]*"([^"]+)"/v\1/p' Cargo.toml | head -1`
|
||||
|
||||
# publish to crates.io
|
||||
@ -70,6 +80,10 @@ install-dev-deps:
|
||||
cargo install -f cargo-check
|
||||
cargo +nightly install cargo-fuzz
|
||||
|
||||
# install system development dependencies with homebrew
|
||||
install-dev-deps-homebrew:
|
||||
brew install help2man
|
||||
|
||||
# everyone's favorite animate paper clip
|
||||
clippy:
|
||||
cargo clippy
|
||||
|
70
man/just.1
Normal file
70
man/just.1
Normal file
@ -0,0 +1,70 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10.
|
||||
.TH JUST "1" "July 2019" "just 0.4.4" "JUST MANUAL"
|
||||
.SH NAME
|
||||
just \- save and run commands
|
||||
.SH DESCRIPTION
|
||||
just 0.4.4
|
||||
\- Please see https://github.com/casey/just for more information.
|
||||
.SS "USAGE:"
|
||||
.IP
|
||||
just [FLAGS] [OPTIONS] [\-\-] [ARGUMENTS]...
|
||||
.SS "FLAGS:"
|
||||
.TP
|
||||
\fB\-\-dry\-run\fR
|
||||
Print what just would do without doing it
|
||||
.TP
|
||||
\fB\-\-dump\fR
|
||||
Print entire justfile
|
||||
.TP
|
||||
\fB\-e\fR, \fB\-\-edit\fR
|
||||
Open justfile with $EDITOR
|
||||
.TP
|
||||
\fB\-\-evaluate\fR
|
||||
Print evaluated variables
|
||||
.TP
|
||||
\fB\-\-highlight\fR
|
||||
Highlight echoed recipe lines in bold
|
||||
.TP
|
||||
\fB\-l\fR, \fB\-\-list\fR
|
||||
List available recipes and their arguments
|
||||
.TP
|
||||
\fB\-q\fR, \fB\-\-quiet\fR
|
||||
Suppress all output
|
||||
.TP
|
||||
\fB\-\-summary\fR
|
||||
List names of available recipes
|
||||
.TP
|
||||
\fB\-v\fR, \fB\-\-verbose\fR
|
||||
Use verbose output
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help information
|
||||
.TP
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
Print version information
|
||||
.SS "OPTIONS:"
|
||||
.HP
|
||||
\fB\-\-color\fR <COLOR>
|
||||
.TP
|
||||
Print colorful output [default: auto]
|
||||
[possible values: auto, always, never]
|
||||
.TP
|
||||
\fB\-f\fR, \fB\-\-justfile\fR <JUSTFILE>
|
||||
Use <JUSTFILE> as justfile.
|
||||
.TP
|
||||
\fB\-\-set\fR <VARIABLE> <VALUE>
|
||||
Set <VARIABLE> to <VALUE>
|
||||
.TP
|
||||
\fB\-\-shell\fR <SHELL>
|
||||
Invoke <SHELL> to run recipes [default: sh]
|
||||
.TP
|
||||
\fB\-s\fR, \fB\-\-show\fR <RECIPE>
|
||||
Show information about <RECIPE>
|
||||
.HP
|
||||
\fB\-d\fR, \fB\-\-working\-directory\fR <WORKING\-DIRECTORY>
|
||||
.IP
|
||||
Use <WORKING\-DIRECTORY> as working directory. \fB\-\-justfile\fR must also be set
|
||||
.SS "ARGS:"
|
||||
.TP
|
||||
<ARGUMENTS>...
|
||||
The recipe(s) to run, defaults to the first recipe in the justfile
|
31
src/run.rs
31
src/run.rs
@ -36,14 +36,7 @@ pub fn run() {
|
||||
let invocation_directory =
|
||||
env::current_dir().map_err(|e| format!("Error getting current directory: {}", e));
|
||||
|
||||
let matches = App::new(env!("CARGO_PKG_NAME"))
|
||||
.version(concat!("v", env!("CARGO_PKG_VERSION")))
|
||||
.author(env!("CARGO_PKG_AUTHORS"))
|
||||
.about(concat!(
|
||||
env!("CARGO_PKG_DESCRIPTION"),
|
||||
" - ",
|
||||
env!("CARGO_PKG_HOMEPAGE")
|
||||
))
|
||||
let app = App::new(env!("CARGO_PKG_NAME"))
|
||||
.help_message("Print help information")
|
||||
.version_message("Print version information")
|
||||
.setting(AppSettings::ColoredHelp)
|
||||
@ -160,8 +153,26 @@ pub fn run() {
|
||||
"SUMMARY",
|
||||
"ARGUMENTS",
|
||||
"EVALUATE",
|
||||
]))
|
||||
.get_matches();
|
||||
]));
|
||||
|
||||
let app = if cfg!(feature = "help4help2man") {
|
||||
app.version(env!("CARGO_PKG_VERSION")).about(concat!(
|
||||
"- Please see ",
|
||||
env!("CARGO_PKG_HOMEPAGE"),
|
||||
" for more information."
|
||||
))
|
||||
} else {
|
||||
app
|
||||
.version(concat!("v", env!("CARGO_PKG_VERSION")))
|
||||
.author(env!("CARGO_PKG_AUTHORS"))
|
||||
.about(concat!(
|
||||
env!("CARGO_PKG_DESCRIPTION"),
|
||||
" - ",
|
||||
env!("CARGO_PKG_HOMEPAGE")
|
||||
))
|
||||
};
|
||||
|
||||
let matches = app.get_matches();
|
||||
|
||||
let color = match matches.value_of("COLOR").expect("`--color` had no value") {
|
||||
"auto" => Color::auto(),
|
||||
|
Loading…
Reference in New Issue
Block a user