From e3259e9721e4d1df93a1022eba99fb8b8e00df22 Mon Sep 17 00:00:00 2001 From: Oliver Atkinson Date: Sun, 20 Aug 2023 07:03:59 -0600 Subject: [PATCH 1/5] stdout help --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index bfd04ca..ac5de40 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,7 +23,7 @@ mod xwrap; use crate::xwrap::Display; fn usage(progname: &str, opts: getopts::Options) { - let brief = format!("Usage: {progname} [options] [file]"); + let brief = format!("Usage: {progname} [options] [file]\nNote: use - as [file] for stdout"); let usage = opts.usage(&brief); eprint!("{usage}"); } From 2bf75f80efffe9c5949a73df7321cf0514c49d15 Mon Sep 17 00:00:00 2001 From: Oliver Atkinson Date: Thu, 31 Aug 2023 23:39:35 -0600 Subject: [PATCH 2/5] Added manpage Added manpage using groff markdown using the man macro. Using `groff -Tascii -man shotgun.man` to transpile. --- shotgun.man | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 shotgun.man diff --git a/shotgun.man b/shotgun.man new file mode 100644 index 0000000..51e756f --- /dev/null +++ b/shotgun.man @@ -0,0 +1,38 @@ +.TH shotgun 1 "08/31/2023" "2.5.1" "User Commands" +.SH NAME +shotgun \- Minimal X screenshot utility +.SH SYNOPSIS +shotgun [\fIOPTIONS\fP] [\fIFILE\fP] +.SH DESCRIPTION +A minimal screenshot utility for X11. +.SS SUPPORTS +.TP +Exporting to PNG/STDOUT +.TP +Masksing off-screen areas on multi-head setups +.TP +Selecting by window ID and geometry +.SS OPTIONS +.TP +\fB-i, --id\fP ID +Window to capture +.TP +\fB-g, --geometry\fP WxH+X+Y +Area to capture +.TP +\fB-f, --format\fP +Either png/pam as output format +.TP +\fB-s, --screen\fP +Capture the current screen +.TP +\fB-h, --help\fP +Print help and exit +.TP +\fB-v, --version\fP +Print version and exit +.SH FILE +\fIfile\fP can be either a file name of which you would like to save the image to, or when using the "-" charicter as the file name it will pipe the image to STDOUT. +.SH AUTHOR +neXromancers + From 80aa266532f00af0c2ddcada328c56d59a5c9186 Mon Sep 17 00:00:00 2001 From: Oliver Atkinson Date: Fri, 1 Sep 2023 01:19:10 -0600 Subject: [PATCH 3/5] Created a manpage This page can be viewed using the `man` command, thus giving you the program's manual. --- shotgun.man => docs/shotgun.1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) rename shotgun.man => docs/shotgun.1 (84%) diff --git a/shotgun.man b/docs/shotgun.1 similarity index 84% rename from shotgun.man rename to docs/shotgun.1 index 51e756f..8ba2757 100644 --- a/shotgun.man +++ b/docs/shotgun.1 @@ -1,5 +1,5 @@ -.TH shotgun 1 "08/31/2023" "2.5.1" "User Commands" -.SH NAME +.TH SHOTGUN 1 "08/31/2023" "2.5.1" "User Commands" +.SH SHOTGUN shotgun \- Minimal X screenshot utility .SH SYNOPSIS shotgun [\fIOPTIONS\fP] [\fIFILE\fP] @@ -35,4 +35,5 @@ Print version and exit \fIfile\fP can be either a file name of which you would like to save the image to, or when using the "-" charicter as the file name it will pipe the image to STDOUT. .SH AUTHOR neXromancers - +.SH BUGS +Please report bugs here: https://github.com/neXromancers/shotgun/issues From 942ec8f1973d1b2362321c15fce2d5b5ab4e0aea Mon Sep 17 00:00:00 2001 From: Oliver Atkinson Date: Fri, 1 Sep 2023 01:21:01 -0600 Subject: [PATCH 4/5] Updated README to mention the avaliablility of a man page. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 842609e..b696da4 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Features: - *On average, shotgun is more than twice as fast as maim* ## Usage +See the man page: `docs/shotgun.1`. ``` Usage: shotgun [options] [file] From e0a2b41950d513543ae7c9fdd0322e93b8a43def Mon Sep 17 00:00:00 2001 From: Oliver Atkinson Date: Fri, 1 Sep 2023 01:26:40 -0600 Subject: [PATCH 5/5] Installing manpage during build.rs There's most likely a better place/way to do this, but it's a start. --- build.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/build.rs b/build.rs index 8e78ac2..ceec72a 100644 --- a/build.rs +++ b/build.rs @@ -1,6 +1,10 @@ +use std::path::Path; use std::process::Command; +use std::{str, env, fs}; fn main() { + add_manpage("shotgun.1"); + let git_version = Command::new("git").arg("describe").arg("--tags").output(); if let Ok(git_version) = git_version { if git_version.status.success() { @@ -10,3 +14,28 @@ fn main() { } } } + +fn add_manpage(manpage: &str) { + let manpage_source_path = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap()).join("docs/").join(manpage); + + let root_path: String = match env::var("CARGO_INSTALL_ROOT") { + Ok(r) => r, + Err(_) => env::var("HOME").unwrap() + "/.cargo/", + }; + let destination_path = root_path + "man/man1/"; + + let manpath = Command::new("manpath").output().expect("Couldn't run \"manpath\"").stdout; + let manpath_parsed = str::from_utf8(&manpath).unwrap(); // could next check $MANPATH, but if the manpath command + // doesn't exsist that probably wont either. It's likely + // they don't have man installed. + if !manpath_parsed.contains(&destination_path) { + println!("cargo:warning=Looks like \"{}\" isn't on your manpath, to see the man page please add it. See `man manpath`", destination_path); + } + + let mut dir_builder = fs::DirBuilder::new(); + dir_builder.recursive(true); + dir_builder.create(&destination_path).expect("Failed to create manpage's parent directories."); + fs::copy(manpage_source_path, destination_path.clone() + manpage).expect(&format!("Failed to install manpage to {}", destination_path)); + +} +