Skip to content
This repository has been archived by the owner on May 20, 2020. It is now read-only.

Commit

Permalink
Merge pull request #197 from euclio/clap-fix
Browse files Browse the repository at this point in the history
add workaround for clap issue
  • Loading branch information
steveklabnik committed Oct 21, 2017
2 parents 01ad9d8 + fc184b7 commit 7eb493b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ static DEFAULT_ARTIFACTS: &[&str] = &["frontend"];
fn run() -> rustdoc::error::Result<()> {
let version = env!("CARGO_PKG_VERSION");

let joined_artifacts = DEFAULT_ARTIFACTS.join(",");
let matches = App::new("rustdoc")
.version(version)
.author("Steve Klabnik <steve@steveklabnik.com>")
Expand All @@ -46,7 +45,6 @@ fn run() -> rustdoc::error::Result<()> {
.use_delimiter(true)
.takes_value(true)
.possible_values(ALL_ARTIFACTS)
.default_value(&joined_artifacts)
.help("Build artifacts to produce. Defaults to just the frontend."),
)
.arg(Arg::with_name("open").short("o").long("open").help(
Expand Down Expand Up @@ -74,7 +72,13 @@ fn run() -> rustdoc::error::Result<()> {

match matches.subcommand() {
("build", Some(matches)) => {
let artifacts: Vec<&str> = matches.values_of("artifacts").unwrap().collect();
// FIXME: Workaround for clap #1056. Use `.default_value()` once the issue is fixed.
let artifacts: Vec<&str> = matches
.values_of("artifacts")
.map(|values| values.collect())
.unwrap_or_else(|| {
DEFAULT_ARTIFACTS.iter().map(|&artifact| artifact).collect()
});
build(&config, &artifacts)?;
if matches.is_present("open") {
config.open_docs()?;
Expand Down

0 comments on commit 7eb493b

Please sign in to comment.