Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate basic man page with help2man #463

Merged
merged 1 commit into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 14 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
70 changes: 70 additions & 0 deletions man/just.1
Original file line number Diff line number Diff line change
@@ -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 changes: 21 additions & 10 deletions src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(),
Expand Down