Question

I'm looking at documentation for thirft code generator. It starts like this:

Usage: thrift [options] file
Options:
  -version    Print the compiler version
  -o dir      Set the output directory for gen-* packages
               (default: current directory)
  -out dir    Set the ouput location for generated files.
               (no gen-* folder will be created)
  -I dir      Add a directory to the list of directories
                searched for include directives
  -nowarn     Suppress all compiler warnings (BAD!)
  -strict     Strict compiler warnings on
  -v[erbose]  Verbose mode
  -r[ecurse]  Also generate included files
  -debug      Parse debug trace to stdout
  --allow-neg-keys  Allow negative field keys (Used to preserve protocol
                compatibility with older .thrift files)
  --allow-64bit-consts  Do not print warnings about using 64-bit constants
  --gen STR   Generate code with a dynamically-registered generator.
                STR has the form language[:key1=val1[,key2,[key3=val3]]].
                Keys and values are options passed to the generator.
                Many options will not require values.

further down there is this:

  java (Java):
    beans:           Members will be private, and setter methods will return void.
    private-members: Members will be private, but setter methods will return 'this' like usual.
    nocamel:         Do not use CamelCase field accessors with beans.
    hashcode:        Generate quality hashCode methods.
    android_legacy:  Do not use java.io.IOException(throwable) (available for Android 2.3 and above).
    java5:           Generate Java 1.5 compliant code (includes android_legacy flag).
    sorted_containers:
                     Use TreeSet/TreeMap instead of HashSet/HashMap as a implementation of set/map.

I got this working: --gen java:beans, but I can't figure out how to include multiple options. I don't understand what this means: language[:key1=val1[,key2,[key3=val3]]]

I have tried things like: "java[:beans,[:hashcode]]", "java:[beans,hashcode]" "java[:beans,:hashcode]" "java:beans java:hashcode" "java[:beans[,hashcode]]" etc.

Was it helpful?

Solution

That's standard notation, and you'll find that all over the place with most command line utilities, even cross-platform. The [ brackets ] enclose optional parameters, the brackets itself are not typed in the command line.

So in your case, you want to do this (example):

thrift -gen java:beans,private-members,nocamel,java5,sorted_containers  yourfile.thrift

to specify five additional options for the java generator. Some rare options also take values, in that case it would be (made up example, not for real):

thrift -gen java:option1=foo,option2,option3=bar  yourfile.thrift

which passes three options, two of which have an value associated.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top