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

add workaround for clap issue #197

Merged
merged 1 commit into from
Oct 21, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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