Protobuf 文件生成工具 Prototool 命令详解

Protobuf 文件生成工具 Prototool 命令详解

简介

Prototool 是 Protobuf 文件的生成工具, 目前支持go, php, java, c#, object c 五种语言包的生成.
详情参考Github: https://github.com/uber/prototool

docker 方式使用 prototool 工具

  • 使用方式
// prototool 的使用
docker run --rm -v $(pwd):/work "uber/prototool" prototool

// 格式化 proto 文件
docker run --rm -v $(pwd):/work "uber/prototool" prototool format -l proto

// 编译, 格式化, 覆盖 proto 文件
docker run --rm -v $(pwd):/work "uber/prototool" prototool all proto
  • docker 方式创建 proto 文件
docker run --rm -v $(pwd):/work "uber/prototool" prototool create test.proto

Prototool 部分命令参数简单介绍

  • prototool lint [目录]

递归的查找所有后缀为 .proto 的文件, 但是不包括 prototool.yamlprototool.json 文件.

prototool lint testdir

注: 不设置目录, 则默认为当前目录. eg: prototool lint .

  • prototool create [test.proto]

创建一个 proto 的模板文件

$ prototool create test.proto
  • prototool files [目录]

列出要被使用的所有 proto 文件

$ prototool files testdir
  • prototool compile [目录]

编译目录下所有的 proto 文件

$ prototool compile testdir
  • prototool generate [目录]

生成 stubs 文件

$ prototool generate testdir
  • prototool 帮助文档

查看帮助文档, 这里详细介绍了命令的使用方式.

$ prototool -h
原文地址:https://www.cnblogs.com/yxhblogs/p/10884602.html