Skip to content

Commit

Permalink
Added --list mode. Closes #23
Browse files Browse the repository at this point in the history
  • Loading branch information
bhermann committed Oct 31, 2018
1 parent a5fb88a commit 944b4b2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/main/scala/de/upb/cs/swt/delphi/cli/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ case class Config(server: String = sys.env.getOrElse("DELPHI_SERVER", "https://d
verbose: Boolean = false,
raw: Boolean = false,
silent: Boolean = false,
list : Boolean = false,
mode: String = "",
query : String = "",
limit : Option[Int] = None,
Expand Down
7 changes: 6 additions & 1 deletion src/main/scala/de/upb/cs/swt/delphi/cli/ConsoleOutput.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ class ConsoleOutput(config: Config) {
case false => {
value match {
case Seq() => ""
case searchResults : Seq[SearchResult] if searchResults.head.isInstanceOf[SearchResult] => ResultBeautifier.beautifySearchResults(searchResults)
case searchResults : Seq[SearchResult] if searchResults.head.isInstanceOf[SearchResult] => {
config.list match {
case true => searchResults.map(_.toMavenIdentifier()).mkString(System.lineSeparator())
case false => ResultBeautifier.beautifySearchResults(searchResults)
}
}
case retrieveResults : Seq[RetrieveResult] if retrieveResults.head.isInstanceOf[RetrieveResult] => ResultBeautifier.beautifyRetrieveResults(retrieveResults)
case _ => value.toString
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/de/upb/cs/swt/delphi/cli/DelphiCLI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ object DelphiCLI extends App {
.text("Search artifact using a query.")
.children(
arg[String]("query").action((x,c) => c.copy(query = x)).text("The query to be used."),
opt[Int]("limit").action((x, c) => c.copy(limit = Some(x))).text("The maximal number of results returned.")
opt[Int]("limit").action((x, c) => c.copy(limit = Some(x))).text("The maximal number of results returned."),
opt[Unit](name="list").action((_, c) => c.copy(list = true)).text("Output results as list (raw option overrides this)")
)
}
}
Expand Down

0 comments on commit 944b4b2

Please sign in to comment.