rustdoc: Add -h flag
This commit is contained in:
parent
362f23641a
commit
6c9527ab79
|
@ -4,6 +4,7 @@ export output_format::{};
|
|||
export output_style::{};
|
||||
export config;
|
||||
export parse_config;
|
||||
export usage;
|
||||
|
||||
#[doc = "The type of document to output"]
|
||||
enum output_format {
|
||||
|
@ -34,20 +35,34 @@ fn opt_output_dir() -> str { "output-dir" }
|
|||
fn opt_output_format() -> str { "output-format" }
|
||||
fn opt_output_style() -> str { "output-style" }
|
||||
fn opt_pandoc_cmd() -> str { "pandoc-cmd" }
|
||||
fn opt_help() -> str { "h" }
|
||||
|
||||
fn opts() -> [(getopts::opt, str)] {
|
||||
[
|
||||
(getopts::optopt(opt_output_dir()),
|
||||
"put documents here"),
|
||||
"--output-dir <val> put documents here"),
|
||||
(getopts::optopt(opt_output_format()),
|
||||
"either 'markdown' or 'html'"),
|
||||
"--output-format <val> either 'markdown' or 'html'"),
|
||||
(getopts::optopt(opt_output_style()),
|
||||
"either 'doc-per-crate' or 'doc-per-mod'"),
|
||||
"--output-style <val> either 'doc-per-crate' or 'doc-per-mod'"),
|
||||
(getopts::optopt(opt_pandoc_cmd()),
|
||||
"the command for running pandoc")
|
||||
"--pandoc-cmd <val> the command for running pandoc"),
|
||||
(getopts::optflag(opt_help()),
|
||||
"-h print help")
|
||||
]
|
||||
}
|
||||
|
||||
fn usage() {
|
||||
import std::io::println;
|
||||
|
||||
println("Usage: rustdoc [options] <cratefile>\n");
|
||||
println("Options:\n");
|
||||
for opt in opts() {
|
||||
println(#fmt(" %s", tuple::second(opt)));
|
||||
}
|
||||
println("");
|
||||
}
|
||||
|
||||
fn default_config(input_crate: str) -> config {
|
||||
{
|
||||
input_crate: input_crate,
|
||||
|
|
|
@ -95,6 +95,11 @@ fn test_run_passes() {
|
|||
|
||||
fn main(argv: [str]) {
|
||||
|
||||
if vec::contains(argv, "-h") {
|
||||
config::usage();
|
||||
ret;
|
||||
}
|
||||
|
||||
if vec::len(argv) != 2u {
|
||||
std::io::println(#fmt("usage: %s <input>", argv[0]));
|
||||
ret;
|
||||
|
|
Loading…
Reference in New Issue