Skip to content

Commit

Permalink
add manpage
Browse files Browse the repository at this point in the history
  • Loading branch information
Kl4rry committed Jun 9, 2024
1 parent 0b89042 commit 5c1b2c7
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 109 deletions.
208 changes: 105 additions & 103 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ avif = ["image/avif-native"]
jxl = ["dep:jpegxl-rs"]
heif = ["dep:libheif-rs"]

[workspace]
members = ["man"]

# Config for 'cargo dist'
[workspace.metadata.dist]
# The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax)
Expand Down
1 change: 1 addition & 0 deletions man/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
simp.1
8 changes: 8 additions & 0 deletions man/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "manpage"
version = "0.1.0"
edition = "2021"

[dependencies]
clap_mangen = "0.2.21"
simp = { version = "*", path = ".."}
23 changes: 23 additions & 0 deletions man/mybin.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.TH simp 1 "simp 3.5.3"
.SH NAME
simp \- The simple image manipulation program
.SH SYNOPSIS
\fBsimp\fR [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fIFILE\fR]
.SH DESCRIPTION
The simple image manipulation program
.SH OPTIONS
.TP
\fB\-h\fR, \fB\-\-help\fR
Print help
.TP
\fB\-V\fR, \fB\-\-version\fR
Print version
.TP
[\fIFILE\fR]
Load this file
.SH VERSION
v3.5.3
.SH AUTHORS
Axel Kappel
7 changes: 7 additions & 0 deletions man/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fn main() {
let cmd = simp::get_clap_command();
let man = clap_mangen::Man::new(cmd);
let mut buffer: Vec<u8> = Default::default();
man.render(&mut buffer).unwrap();
std::fs::write("simp.1", buffer).unwrap();
}
7 changes: 7 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pub fn get_clap_command() -> clap::Command {
clap::Command::new(env!("CARGO_PKG_NAME"))
.author(env!("CARGO_PKG_AUTHORS"))
.about(env!("CARGO_PKG_DESCRIPTION"))
.version(env!("CARGO_PKG_VERSION"))
.arg(clap::Arg::new("FILE").help("Load this file").index(1))
}
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod cli;

pub use cli::get_clap_command;
8 changes: 2 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use winit::{
keyboard::{Key, ModifiersState},
window::{Window, WindowBuilder},
};
mod cli;
mod image_io;

#[derive(Serialize, Deserialize, Debug, Default)]
Expand Down Expand Up @@ -434,12 +435,7 @@ fn main() {
std::process::exit(1);
}));

let matches = clap::Command::new(env!("CARGO_PKG_NAME"))
.author(env!("CARGO_PKG_AUTHORS"))
.about(env!("CARGO_PKG_DESCRIPTION"))
.version(env!("CARGO_PKG_VERSION"))
.arg(clap::Arg::new("FILE").help("Load this file").index(1))
.get_matches();
let matches = cli::get_clap_command().get_matches();

let path: Option<&String> = matches.get_one("FILE");

Expand Down

0 comments on commit 5c1b2c7

Please sign in to comment.