-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Labels
A-docArea: Documenting your CLI (e.g. man pages)Area: Documenting your CLI (e.g. man pages)C-tracking-issueCategory: A tracking issue for an unstable featureCategory: A tracking issue for an unstable feature
Description
This is a tracking issue for man page creation. The initial goal is to provide a flow to generate man pages from Structopt instances. This is a specialization of https://github.com/rust-lang-nursery/cli-wg/issues/23.
Example
The goal is to be able to use code similar to this.
// src/cli.rs
extern crate structopt;
#[derive(StructOpt, Debug)]
pub struct Opts {
/// TCP port to listen to.
#[structopt(
short = "p", long = "port", env = "PORT", default_value = "8080"
)]
port: usize,
}// src/lib.rs
#[macro_use]
extern crate structopt;
pub mod cli;// build.rs
extern crate structop_to_man;
use structopt::{clap::Shell, StructOpt};
include!("src/lib.rs");
fn main() {
let outdir = ::std::env::var_os("OUT_DIR").expect("OUT_DIR not found.");
let mut app = cli::Opts::clap();
app.gen_completions("my_app", Shell::Fish, &outdir); // generate shell completions
structop_to_man::gen_man(&app, &outdir); // generate man pages
}Checklist
I think the following steps are required to make this happen.
- Base man page generator (roff) - https://github.com/killercup/roff-rs
- Higher level man page generator (wrap roff, write to
Writer). - Parse Clap struct & convert to individual fields (see Question: how to extract {flags, opts, subcommands, ...} clap-rs/clap#1285 for current status).
- Combine Clap struct parser + man page generator into single crate that can generate a man page and write it to
Writer.
alexreg and jens1o
Metadata
Metadata
Assignees
Labels
A-docArea: Documenting your CLI (e.g. man pages)Area: Documenting your CLI (e.g. man pages)C-tracking-issueCategory: A tracking issue for an unstable featureCategory: A tracking issue for an unstable feature