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

API design #2

Open
yoshuawuyts opened this issue Jun 21, 2018 · 2 comments
Open

API design #2

yoshuawuyts opened this issue Jun 21, 2018 · 2 comments

Comments

@yoshuawuyts
Copy link
Collaborator

The current API is more of a sketch of what this could look like. On chat there seems to be a sentiment that the current API might not suffice for more complex man pages.

I'm opening this issue to gather examples of complex man pages, and to help shape the design of the crate. This should hopefully allow us to get a deeper understanding of which API we can, and should expose.

@epage
Copy link

epage commented Jun 21, 2018

Not sure but my guess is more a matter of single sourcing

  • header information pulled from Cargo.toml
  • flags pulled from clap
  • body pulled from markdown that can also be used as web documentation

Granted, if this is a lower level API, then it might make sense to not have all of that built in

@yoshuawuyts yoshuawuyts mentioned this issue Jul 19, 2018
@yoshuawuyts
Copy link
Collaborator Author

I think clap actually has a really neat API. Taking some notes on the structure would probably be a good idea. https://github.com/kbknapp/clap-rs#quick-example

extern crate clap;
extern crate clap_md;

use clap::{App, AppSettings, Arg, SubCommand};
use clap_md::app_to_md;

fn main() {
  let a = App::new("testapp")
    .about("Pointless application")
    .setting(AppSettings::SubcommandRequiredElseHelp)
    .author("Katharina Fey <kookie@spacekookie.de>")
    // .author("Yosh Wuyts <y@w.s")
    .long_about("Lorem Ipsum bla bla bla")
    .arg(Arg::with_name("debug").short("d").help("Make program output debug messages"))
    .arg(Arg::with_name("output").short("o").takes_value(true).help("Output File"))
    .subcommand(SubCommand::with_name("foo").arg(Arg::with_name("bar").short("b").long("barr")));

  let markdown = app_to_md(&a, 1).unwrap();
  println!("{}", markdown);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants