Skip to content

Instantly share code, notes, and snippets.

@ottomata
Last active July 25, 2017 17:06
Show Gist options
  • Select an option

  • Save ottomata/ce393c836742cee1f96d550796f98db2 to your computer and use it in GitHub Desktop.

Select an option

Save ottomata/ce393c836742cee1f96d550796f98db2 to your computer and use it in GitHub Desktop.
// Support implicit conversion from regex string CLI opt to matching filter function.
implicit val scoptFilterRegexRead: scopt.Read[(String) => Boolean] = scopt.Read.reads { s =>
val regex = s.r
(string: String) => {
string match {
case regex(_*) => true
case _ => false
}
}
}
...
opt[(String) => Boolean]('w', "topic-whitelist") optional() valueName "<topic-whitelist>" action { (x, p) =>
p.copy(topicWhitelistFilter = x)
} text """Whitelist regex of topics imported by Camus to refine.""".stripMargin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment