# idl-generator-cli **Repository Path**: l0km/idl-generator-cli ## Basic Information - **Project Name**: idl-generator-cli - **Description**: 项目已经代码移到 https://gitee.com/l0km/idl-generator - **Primary Language**: Java - **License**: BSD-2-Clause - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2017-12-16 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: utils **Tags**: None ## README # idl-generator-cli 在[swift2thrift-generator-cli][1](0.14.2)基础上定制idl文件生成,将primitive封装类型(Integer,Long,Boolean...)的参数和字段在生成的IDL文件中默认指定为optional,将primitive类型的参数和字段默认指定为required. 命令行参数与swift提供的[swift2thrift-generator-cli][1]保持一致,增加了一个命令行参数`-primitiveOptional`(默认true),当指定为false时生成的idl文件与swift2thrift-generator-cli完全一致。 Usage: Swift2ThriftGenerator [options] Options: -allow_multiple_packages Allow input classes to reside in different packages. The value of this flag defines the generated java.swift namespace. Note that Swift classes generated from the resultant Thrift file will all reside in one Java package -package, -default_package Default package for unqualified classes Default: -map Map of external type or service to include file -namespace Namespace for a particular language to include -out Thrift IDL output file, defaults to stdout -primitiveOptional Generate optional field and parameter from the wrap type of primitive type(such as Integer,Long...) Default: true -recursive Generate all types transitively reachable from the specified types and services Default: false -v, -verbose Show verbose messages Default: false 使用示例(注意以下为windows bat脚本,路径分隔符为windows下的`;`): set MYCLASS=target\classes;..\db\target\classes;..\simplemq\target\classes java -cp lib\idl-generator-cli-1.0-SNAPSHOT-standalone.jar;%MYCLASS% ^ com.gitee.l0km.thrift.swift2thrift.generator.Main ^ -namespace py gdface.thrift ^ -namespace java com.gdface -namespace cpp gdface ^ -out IFaceLog.thrift ^ -package net.gdface.facelog.service BaseFaceLog ^ -recursive 1. MYCLASS 定义要生成idl文件的class路径(claspath) 2. -namespace 用于指定生成对应语言(java,cpp,python...)代码的名字空间 3. -out 指定生成的idl文件名 4. -package 指定生成servcie接口的类包名 BaseFaceLog就是的service定义类名 5. -recursive 指定生成service相关的所有引用类型的idl 关于参数的更详细权威的用法说明参见原版[swift2thrift-generator-cli][1]及[《thrift:swift 命令行生成 IDL文件及Client java代码过程》][2] [1]:https://github.com/facebook/swift/tree/master/swift2thrift-generator-cli [2]:http://blog.csdn.net/10km/article/details/78203926