diff options
author | Paul Phillips <paulp@improving.org> | 2010-04-21 17:06:38 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-04-21 17:06:38 +0000 |
commit | a17a4dc15730ce004ca8c9495c850dfca1062c24 (patch) | |
tree | 5dbd27fc4476a3bd3f16d1fbbee4647b633f242b /src/compiler/scala/tools/cmd/CommandLine.scala | |
parent | cf26f620707be4bd9f8bc30a733eb4a987894421 (diff) | |
download | scala-a17a4dc15730ce004ca8c9495c850dfca1062c24.tar.gz scala-a17a4dc15730ce004ca8c9495c850dfca1062c24.tar.bz2 scala-a17a4dc15730ce004ca8c9495c850dfca1062c24.zip |
Since pickled data moved into annotations ShowP...
Since pickled data moved into annotations ShowPickled has been
confusedly scratching its head. Made tools/showPickled work again. In
the process created a simple interface for creating command line tools
for the (majority of) commands which would just like to specify a
handful of options. No review.
Diffstat (limited to 'src/compiler/scala/tools/cmd/CommandLine.scala')
-rw-r--r-- | src/compiler/scala/tools/cmd/CommandLine.scala | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/src/compiler/scala/tools/cmd/CommandLine.scala b/src/compiler/scala/tools/cmd/CommandLine.scala index deedf38e93..9b8bef4a9a 100644 --- a/src/compiler/scala/tools/cmd/CommandLine.scala +++ b/src/compiler/scala/tools/cmd/CommandLine.scala @@ -8,18 +8,19 @@ package cmd import scala.collection.mutable.ListBuffer +trait CommandLineConfig { + def enforceArity: Boolean = true + def onlyKnownOptions: Boolean = true +} + /** An instance of a command line, parsed according to a Spec. */ -class CommandLine(val spec: Reference, val originalArgs: List[String]) { +class CommandLine(val spec: Reference, val originalArgs: List[String]) extends CommandLineConfig { def this(spec: Reference, line: String) = this(spec, Parser tokenize line) def this(spec: Reference, args: Array[String]) = this(spec, args.toList) import spec.{ isAnyOption, isUnaryOption, isBinaryOption, isExpandOption } - def assumeBinary = true - def enforceArity = true - def onlyKnownOptions = false - val Terminator = "--" val ValueForUnaryOption = "true" // so if --opt is given, x(--opt) = true @@ -88,23 +89,3 @@ class CommandLine(val spec: Reference, val originalArgs: List[String]) { override def toString() = argMap.toString + " " + residualArgs.toString } - -object CommandLine { - def apply(args: List[String], unary: List[String], binary: List[String]) = { - /** XXX Temporarily assembling a fake spec so we can continue to - * do ad-hoc parsing based on a list of unary and binary args. - * Should either clean this up or do it differently. - */ - object NoSpec extends Reference { - unary foreach (_ --? ) - binary foreach (_ --| ) - - protected def creator(args: List[String]) = error("No Spec") - def programInfo = Spec.Names("", "") - lazy val referenceSpec = this - } - - new CommandLine(NoSpec, args) - } -} - |