LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

thrift

Apache Thrift cross-language code generator

TLDR

Generate code for a specific language from a Thrift file
$ thrift --gen [language] [file.thrift]
copy
Generate code in a specific output directory
$ thrift --gen [language] -o [output_directory] [file.thrift]
copy
Generate code with language-specific options
$ thrift --gen [language]:key1=val1,key2=val2 [file.thrift]
copy
Generate code including all referenced Thrift files
$ thrift -r --gen [language] [file.thrift]
copy
Add include search paths for Thrift imports
$ thrift -I [include_dir] --gen [language] [file.thrift]
copy
List all available generators
$ thrift --help
copy

SYNOPSIS

thrift [-o dir] [-out dir] [-I dir] [-nowarn] [-strict] [-v] [-r] [-debug] --gen lang[:options] file.thrift

DESCRIPTION

thrift is the compiler for Apache Thrift, a framework for scalable cross-language services development. It combines a software stack with a code generation engine to build efficient and seamless services between languages like C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, JavaScript, Node.js, and more.The compiler reads a Thrift Interface Definition Language (IDL) file containing struct and service definitions, then generates language-specific implementation code. This enables developers to define data types and service interfaces once and generate the boilerplate code for multiple programming languages.Common generators include: cpp, java, py, rb, php, js, go, rs (Rust), swift, and many others. Run thrift without arguments to see all available generators for your installation.

PARAMETERS

--gen lang[:key=val,...]

Generate code with the specified generator. Language options can be passed as comma-separated key=value pairs.
-o dir
Set the output directory for gen-* packages. Default is the current directory.
-out dir
Set the output location directly without creating a gen-* folder.
-I dir
Add a directory to search for include directives. Can be specified multiple times.
-r, --recurse
Also generate code for included Thrift files recursively.
-nowarn
Suppress all compiler warnings.
-strict
Enable strict compiler warnings.
-v, --verbose
Enable verbose output mode.
-debug
Print parse debug trace to stdout.
-version
Print the compiler version and exit.

INSTALL

sudo apt install thrift-compiler
copy
sudo dnf install thrift
copy
sudo pacman -S thrift
copy
sudo apk add thrift
copy
sudo zypper install thrift
copy
brew install thrift
copy
nix profile install nixpkgs#thrift
copy

CAVEATS

Generated code structure and options vary significantly between language generators. Some generators may require additional runtime libraries to be installed. The -nowarn flag is generally discouraged as it can hide important compatibility issues.

HISTORY

Apache Thrift was originally developed at Facebook in 2007 and was open-sourced in April 2008. It became an Apache Incubator project in May 2008 and graduated to a top-level Apache project in October 2010. The framework was designed to enable efficient and reliable communication across programming languages at scale.

SEE ALSO

protoc(1), grpc(1)

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid