Skip to content

Commit

Permalink
Add hack to allow cleaner command line opts
Browse files Browse the repository at this point in the history
  • Loading branch information
johannescoetzee committed Jul 19, 2023
1 parent 83f6926 commit 640292e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ object JavaSrc2Cpg {
JavaSrcEnvVar.values.foreach { envVar =>
val currentValue = Option(System.getenv(envVar.name)).getOrElse("<unset>")
println(s"${envVar.name}:")
println(s"- Description : ${envVar.description}")
println(s"- Current value: $currentValue")
println(s" Description : ${envVar.description}")
println(s" Current value: $currentValue")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,23 @@ private object Frontend {
.text("JDK used for resolving builtin Java types. If not set, current classpath will be used"),
opt[Unit]("show-env")
.action((_, c) => c.withShowEnv(true))
// This should really be a print-and-exit but, with the current scopt setup, input paths
// are still required, so for now `javasrc2cpg --show-env <inputs>` is less confusing
// than `javasrc2cpg --show-env <dummy input to keep scopt happy>`
.text("print information about environment variables used by javasrc2cpg prior to analysis")
.text("print information about environment variables used by javasrc2cpg prior to analysis and exit.")
)
}
}

object Main extends X2CpgMain(cmdLineParser, new JavaSrc2Cpg()) {

override def main(args: Array[String]): Unit = {
// TODO: This is a hack to allow users to use the "--show-env" option without having
// to specify an input argument. Clean this up when adding this option to more frontends.
if (args.contains("--show-env")) {
super.main(Array("--show-env", "<input_dir_placeholder>"))
} else {
super.main(args)
}
}

def run(config: Config, javasrc2Cpg: JavaSrc2Cpg): Unit = {
if (config.showEnv) {
JavaSrc2Cpg.showEnv()
Expand Down

0 comments on commit 640292e

Please sign in to comment.