diff --git a/Cargo.toml b/Cargo.toml index a0cc563..e6e53b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/justfile b/justfile index 9c6e9d2..8ec3765 100755 --- a/justfile +++ b/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 diff --git a/man/just.1 b/man/just.1 new file mode 100644 index 0000000..74d2aec --- /dev/null +++ b/man/just.1 @@ -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 +.TP +Print colorful output [default: auto] +[possible values: auto, always, never] +.TP +\fB\-f\fR, \fB\-\-justfile\fR +Use as justfile. +.TP +\fB\-\-set\fR +Set to +.TP +\fB\-\-shell\fR +Invoke to run recipes [default: sh] +.TP +\fB\-s\fR, \fB\-\-show\fR +Show information about +.HP +\fB\-d\fR, \fB\-\-working\-directory\fR +.IP +Use as working directory. \fB\-\-justfile\fR must also be set +.SS "ARGS:" +.TP +... +The recipe(s) to run, defaults to the first recipe in the justfile diff --git a/src/run.rs b/src/run.rs index 75d018e..13e205d 100644 --- a/src/run.rs +++ b/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(),