mirror of
https://github.com/nasa/fpp.git
synced 2025-12-15 21:08:16 -06:00
Revise top-level tool code
This commit is contained in:
parent
e420a3322d
commit
bad0323101
@ -22,29 +22,18 @@ object FPPSyntax {
|
||||
case Nil => List(File.StdIn)
|
||||
case list => list
|
||||
}
|
||||
val result = Result.seq(
|
||||
Result.seq(
|
||||
Result.map(files, Parser.parseFile (Parser.transUnit) (None) _),
|
||||
List(resolveIncludes (options) _, printAst (options) _)
|
||||
)
|
||||
result match {
|
||||
case Left(error) => {
|
||||
error.print
|
||||
errorExit
|
||||
}
|
||||
case _ => ()
|
||||
}
|
||||
}
|
||||
|
||||
def errorExit = System.exit(1)
|
||||
def main(args: Array[String]) =
|
||||
Tool(name).mainMethod(args, oparser, Options(), command)
|
||||
|
||||
def main(args: Array[String]) = {
|
||||
OParser.parse(oparser, args, Options()) match {
|
||||
case Some(options) => command(options)
|
||||
case None => errorExit
|
||||
}
|
||||
}
|
||||
|
||||
def printAst(options: Options)(tul: List[Ast.TransUnit]): Result.Result[List[Ast.TransUnit]] = {
|
||||
def printAst(options: Options)(tul: List[Ast.TransUnit]):
|
||||
Result.Result[List[Ast.TransUnit]] =
|
||||
{
|
||||
options.ast match {
|
||||
case true => {
|
||||
val lines = tul.map(AstWriter.transUnit).flatten
|
||||
@ -55,7 +44,9 @@ object FPPSyntax {
|
||||
Right(tul)
|
||||
}
|
||||
|
||||
def resolveIncludes(options: Options)(tul: List[Ast.TransUnit]): Result.Result[List[Ast.TransUnit]] = {
|
||||
def resolveIncludes(options: Options)(tul: List[Ast.TransUnit]):
|
||||
Result.Result[List[Ast.TransUnit]] =
|
||||
{
|
||||
options.include match {
|
||||
case true => for {
|
||||
result <- ResolveSpecInclude.transformList(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user