Permalink
Browse files

updated readme, trimmed command line options

  • Loading branch information...
1 parent cce5405 commit 26d7ec9092ff1eacc2b1365c82ce4a523b52eb89 Jeremy Cloud committed Aug 15, 2011
Showing with 28 additions and 22 deletions.
  1. +23 −10 README.md
  2. +5 −12 src/main/scala/com/twitter/scrooge/Main.scala
View
@@ -1,5 +1,4 @@
-
-## scrooge
+# scrooge
Scrooge is a thrift code generator for scala.
@@ -12,14 +11,14 @@ It also uses scala syntax so the generated code is much smaller.
The generated code still depends on libthrift.
-# Building
+## Building
To build scrooge, use sbt:
$ sbt package-dist
-# Work in progress
+## Work in progress
This is still a work in progress, so patches and help are gleefully accepted.
@@ -33,12 +32,26 @@ The state (as of July 2011):
The "master" branch uses sbt-thrift (apache thrift with scala wrappers) and
the "scrooge" branch uses scrooge.
-- To run the code generator, just do:
+- There's no sbt plugin yet, but there should be.
+
+## Running Scrooge
- $ ./scrooge \<thrift-file\>
+This assumes that you have a script named "scrooge" in your path.
- and it will spew all the generated code to stdout. This is not intended to
- be the final behavior -- just a stopgap. It really should take some options
- and write out several files to a single path.
+- To get command line help:
-- There's no sbt plugin yet, but there should be.
+ `$ ./scrooge -?`
+
+- To generate source with content written to the current directory:
+
+ `$ ./scrooge <thrift-file1> [<thrift-file2> ...]`
+
+- To generate source with content written to a specified directory:
+
+ `$ ./scrooge -d <target-dir> <thrift-file1> [<thrift-file2> ...]`
+
+- To specify additional include paths:
+
+ `$ ./scrooge -i <include-path> <thrift-file1> [<thrift-file2> ...]`
+
+ Where include-path is a list of directory, separated by the platform specified path separator (':' on unix, ';' on windows)
@@ -7,16 +7,13 @@ object Main {
object Options extends CommandLineParser {
val version = Flag("v", "version", "Print version number and quit")
val help = Flag("?", "help", "Print help and quit")
- val genClient = Flag("c", "generate-client", "Generate finagle client")
- val genService = Flag("s", "generate-service", "Generate finagle service")
- val genServer = Flag("o", "generate-server", "Generate ostrich server")
val outputDir = StringOption("d", "output-dir", "path", "path of the directory to write files to")
val outputFile = StringOption("o", "output-file", "filename", "name of file to write output to")
val importPath = StringOption("i", "import-path", "path", "path-separator separated list of paths")
val inputFiles = NakedArgument("inputFiles", true, true, "The name of the thrift files to process")
val versionMode = %(version)
val helpMode = %(help)
- val genMode = %(importPath.? ~ (outputFile | outputDir).? ~ genClient.? ~ genService.? ~ genServer.?, inputFiles)
+ val genMode = %(importPath.? ~ (outputFile | outputDir).?, inputFiles)
val spec = %%(versionMode, helpMode, genMode)
}
@@ -34,14 +31,10 @@ object Main {
case Right((Options.genMode, cmdLine)) =>
val importPath = cmdLine(Options.importPath).map(_.split(File.pathSeparator).toSeq).getOrElse(Nil)
- val genClient = cmdLine(Options.genClient)
- val genService = cmdLine(Options.genService)
- val genServer = cmdLine(Options.genServer)
- val genAll = !genClient && !genService && !genServer // default to all if none-specified
- val genOptions = Set[scalagen.ScalaServiceOption]() ++
- (if (genClient || genAll) Set(scalagen.WithFinagleClient) else Set()) ++
- (if (genService || genAll) Set(scalagen.WithFinagleService) else Set()) ++
- (if (genServer || genAll) Set(scalagen.WithOstrichServer) else Set())
+ val genOptions = Set[scalagen.ScalaServiceOption](
+ scalagen.WithFinagleClient,
+ scalagen.WithFinagleService,
+ scalagen.WithOstrichServer)
for (inputFile <- cmdLine(Options.inputFiles)) {
val inputFileDir = new File(inputFile).getParent()

0 comments on commit 26d7ec9

Please sign in to comment.