Skip to content

Commit

Permalink
Fix wrong multifilter parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsanchezq committed Sep 17, 2021
1 parent 94e5f48 commit 37afd46
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/bin/cli/ideascale/mod.rs
Expand Up @@ -27,6 +27,10 @@ pub enum Ideascale {
Import(Import),
}

// We need this type because structopt uses Vec<String> as a special type, so it is not compatible
// with custom parsers feature.
type Filters = Vec<String>;

#[derive(Debug, StructOpt)]
#[structopt(rename_all = "kebab")]
pub struct Import {
Expand Down Expand Up @@ -63,8 +67,8 @@ pub struct Import {
tags: Option<PathBuf>,

/// Ideascale stages list,
#[structopt(long, default_value = "'Governance phase' 'Assess QA'")]
stages_filters: Vec<String>,
#[structopt(long, parse(from_str=parse_from_csv), default_value = "Governance phase;Assess QA")]
stages_filters: Filters,
}

impl Ideascale {
Expand All @@ -89,6 +93,8 @@ impl Import {
stages_filters,
} = self;

println!("{:?}", stages_filters);

let tags: CustomFieldTags = if let Some(tags_path) = tags {
read_tags_from_file(tags_path)?
} else {
Expand Down Expand Up @@ -154,3 +160,7 @@ fn read_tags_from_file(file_path: &Path) -> Result<CustomFieldTags, Error> {
let reader = io_utils::open_file_read(&Some(file_path))?;
serde_json::from_reader(reader).map_err(Error::Serde)
}

fn parse_from_csv(s: &str) -> Filters {
s.split(";").map(|x| x.to_string()).collect()
}

0 comments on commit 37afd46

Please sign in to comment.