diff --git a/src/bin/cli/ideascale/mod.rs b/src/bin/cli/ideascale/mod.rs index 75b94e40..1a80a410 100644 --- a/src/bin/cli/ideascale/mod.rs +++ b/src/bin/cli/ideascale/mod.rs @@ -27,6 +27,10 @@ pub enum Ideascale { Import(Import), } +// We need this type because structopt uses Vec as a special type, so it is not compatible +// with custom parsers feature. +type Filters = Vec; + #[derive(Debug, StructOpt)] #[structopt(rename_all = "kebab")] pub struct Import { @@ -63,8 +67,8 @@ pub struct Import { tags: Option, /// Ideascale stages list, - #[structopt(long, default_value = "'Governance phase' 'Assess QA'")] - stages_filters: Vec, + #[structopt(long, parse(from_str=parse_from_csv), default_value = "Governance phase;Assess QA")] + stages_filters: Filters, } impl Ideascale { @@ -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 { @@ -154,3 +160,7 @@ fn read_tags_from_file(file_path: &Path) -> Result { 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() +}