<commit_before># Scrooge
[![Build Status](https://secure.travis-ci.org/twitter/scrooge.png)](http://travis-ci.org/twitter/scrooge)

Scrooge is a [thrift](http://thrift.apache.org/) code generator written in
Scala, which currently generates code for Scala and Java.

It's meant to be a replacement for the apache thrift code generator, and
generates conforming, compatible binary codecs by building on top of
libthrift.

Since Scala is API-compatible with Java, you can use the apache thrift code
generator to generate Java files and use them from within Scala, but the
generated code uses Java collections and mutable "bean" classes, causing some
annoying boilerplate conversions to be hand-written. This is an attempt to
bypass the problem by generating Scala code directly. It also uses Scala
syntax so the generated code is much more compact.

There is a fairly comprehensive set of unit tests, which actually generate
code, compile it, and execute it to verify expectations.

There are two sub-projects:

- scrooge-generator: the code generator
- scrooge-runtime: some base traits used by the generated code


## Features

- Generates native Scala thrift codecs, in immutable and "builder" variants,
  using case classes and functions.

- Generated code is templated using a mustache variant, making it easy to
  edit.

- Finagle client/server adaptors, and Ostrich wrappers, can be optionally
  generated at the same time.


## Building Scrooge

To build scrooge, use sbt:

    $ ./sbt +publish-local

## Runtime dependency

There are a couple of classes needed by the generated code. These have been
moved out of scrooge into a separate jar to keep dependencies small.
Maven users need to add the following to the pom.xml file:

    <dependency>
      <groupId>com.twitter</groupId>
      <artifactId>scrooge-runtime_2.9.2</artifactId>
      <version>3.2.1</version>
    </dependency>

SBT users need this:

    val scrooge_runtime = "com.twitter" %% "scrooge-runtime" % "3.2.1"

## Running Scrooge as a command line tool

To get command line help:

    $ scrooge --help

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, using
extra include paths, rebuilding only those files that have changed:

    $ scrooge
      -d <target-dir>
      -i <include-path>
      -s
      <thrift-file1> [<thrift-file2> ...]

A complete command line help menu:

    Usage: scrooge [options] <files...>

      --help
            show this help screen
      -V | --version
            print version and quit
      -v | --verbose
            log verbose messages about progress
      -d <path> | --dest <path>
            write generated code to a folder (default: .)
      -i <path> | --import-path <path>
            path(s) to search for imported thrift files (may be used multiple times)
      -n <oldname>=<newname> | --namespace-map <oldname>=<newname>
            map old namespace to new (may be used multiple times)
      --disable-strict
            issue warnings on non-severe parse errors instead of aborting
      -s | --skip-unchanged
            Don't re-generate if the target is newer than the input
      -l <value> | --language <value>
            name of language to generate code in ('Java' and 'Scala' are currently supported)
      --finagle
            generate finagle classes
      --ostrich
            generate ostrich server interface
      <files...>
            thrift files to compile

## SBT Plugin

Add a line like this to your `plugins.sbt` file:

    addSbtPlugin("com.twitter" %% "scrooge-sbt-plugin" % "3.1.5")

In your `build.sbt` file:

    com.twitter.scrooge.ScroogeSBT.newSettings

    libraryDependencies ++= Seq(
      "org.apache.thrift" % "libthrift" % "0.8.0",
      "com.twitter" %% "scrooge-runtime" % "3.1.5",
      "com.twitter" %% "finagle-thrift" % "6.4.0"
    )<commit_msg>Make latest runtime version consistent<commit_after># Scrooge
[![Build Status](https://secure.travis-ci.org/twitter/scrooge.png)](http://travis-ci.org/twitter/scrooge)

Scrooge is a [thrift](http://thrift.apache.org/) code generator written in
Scala, which currently generates code for Scala and Java.

It's meant to be a replacement for the apache thrift code generator, and
generates conforming, compatible binary codecs by building on top of
libthrift.

Since Scala is API-compatible with Java, you can use the apache thrift code
generator to generate Java files and use them from within Scala, but the
generated code uses Java collections and mutable "bean" classes, causing some
annoying boilerplate conversions to be hand-written. This is an attempt to
bypass the problem by generating Scala code directly. It also uses Scala
syntax so the generated code is much more compact.

There is a fairly comprehensive set of unit tests, which actually generate
code, compile it, and execute it to verify expectations.

There are two sub-projects:

- scrooge-generator: the code generator
- scrooge-runtime: some base traits used by the generated code


## Features

- Generates native Scala thrift codecs, in immutable and "builder" variants,
  using case classes and functions.

- Generated code is templated using a mustache variant, making it easy to
  edit.

- Finagle client/server adaptors, and Ostrich wrappers, can be optionally
  generated at the same time.


## Building Scrooge

To build scrooge, use sbt:

    $ ./sbt +publish-local

## Runtime dependency

There are a couple of classes needed by the generated code. These have been
moved out of scrooge into a separate jar to keep dependencies small.
Maven users need to add the following to the pom.xml file:

    <dependency>
      <groupId>com.twitter</groupId>
      <artifactId>scrooge-runtime_2.9.2</artifactId>
      <version>3.2.1</version>
    </dependency>

SBT users need this:

    val scrooge_runtime = "com.twitter" %% "scrooge-runtime" % "3.2.1"

## Running Scrooge as a command line tool

To get command line help:

    $ scrooge --help

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, using
extra include paths, rebuilding only those files that have changed:

    $ scrooge
      -d <target-dir>
      -i <include-path>
      -s
      <thrift-file1> [<thrift-file2> ...]

A complete command line help menu:

    Usage: scrooge [options] <files...>

      --help
            show this help screen
      -V | --version
            print version and quit
      -v | --verbose
            log verbose messages about progress
      -d <path> | --dest <path>
            write generated code to a folder (default: .)
      -i <path> | --import-path <path>
            path(s) to search for imported thrift files (may be used multiple times)
      -n <oldname>=<newname> | --namespace-map <oldname>=<newname>
            map old namespace to new (may be used multiple times)
      --disable-strict
            issue warnings on non-severe parse errors instead of aborting
      -s | --skip-unchanged
            Don't re-generate if the target is newer than the input
      -l <value> | --language <value>
            name of language to generate code in ('Java' and 'Scala' are currently supported)
      --finagle
            generate finagle classes
      --ostrich
            generate ostrich server interface
      <files...>
            thrift files to compile

## SBT Plugin

Add a line like this to your `plugins.sbt` file:

    addSbtPlugin("com.twitter" %% "scrooge-sbt-plugin" % "3.1.5")

In your `build.sbt` file:

    com.twitter.scrooge.ScroogeSBT.newSettings

    libraryDependencies ++= Seq(
      "org.apache.thrift" % "libthrift" % "0.8.0",
      "com.twitter" %% "scrooge-runtime" % "3.2.1",
      "com.twitter" %% "finagle-thrift" % "6.4.0"
    )
{'fraction_non_alphanumeric': 0.08885523160419033, 'fraction_numerical': 0.006310740880979427, 'mean_word_length': 2.920831271647699, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 55, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2907040', 'n_tokens_mistral': 2331, 'n_tokens_neox': 2269, 'n_words': 934}