diff options
| author | Chick Markley | 2017-09-19 12:02:29 -0700 |
|---|---|---|
| committer | GitHub | 2017-09-19 12:02:29 -0700 |
| commit | 893ed22449edf83e6773feff8058d6ceb64ae984 (patch) | |
| tree | 5cf0c4cf445288d3eaafe5c8a392b6c69ad4cc78 /src | |
| parent | a4c072d5afd56cbc1d8292c865e9f8331d6e6f0f (diff) | |
Provide mechanism so that programs can optionally (#660)
not exit when --help is included in program flags
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/firrtl/ExecutionOptionsManager.scala | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/main/scala/firrtl/ExecutionOptionsManager.scala b/src/main/scala/firrtl/ExecutionOptionsManager.scala index 4ffc7915..8d071902 100644 --- a/src/main/scala/firrtl/ExecutionOptionsManager.scala +++ b/src/main/scala/firrtl/ExecutionOptionsManager.scala @@ -18,8 +18,25 @@ import scala.collection.Seq trait ComposableOptions abstract class HasParser(applicationName: String) { - final val parser: OptionParser[Unit] = new OptionParser[Unit](applicationName) {} -} + final val parser = new OptionParser[Unit](applicationName) { + var terminateOnExit = true + override def terminate(exitState: Either[String, Unit]): Unit = { + if(terminateOnExit) sys.exit(0) + } + } + + /** + * By default scopt calls sys.exit when --help is in options, this defeats that + */ + def doNotExitOnHelp(): Unit = { + parser.terminateOnExit = false + } + /** + * By default scopt calls sys.exit when --help is in options, this un-defeats doNotExitOnHelp + */ + def exitOnHelp(): Unit = { + parser.terminateOnExit = true + }} /** * Most of the chisel toolchain components require a topName which defines a circuit or a device under test. |
