Skip to content

Commit b2d986a

Browse files
committed
support printing version and help
1 parent 5bb5766 commit b2d986a

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

lib/protobuf/protoc/cli.ex

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
defmodule Protobuf.Protoc.CLI do
2+
@moduledoc false
3+
4+
def main(["--version"]) do
5+
{:ok, version} = :application.get_key(:protobuf, :vsn)
6+
IO.puts to_string(version)
7+
end
8+
9+
def main([opt]) when opt in ["--help", "-h"] do
10+
IO.puts """
11+
protoc plugin for generating Elixir code
12+
13+
See `protoc -h` and protobuf-elixir for details.
14+
NOTICE: protoc-gen-elixir(this name is important) must be in $PATH
15+
16+
Examples:
17+
$ protoc --elixir_out=./lib your.proto
18+
$ protoc --elixir_out=plugins=grpc:./lib/ *.proto
19+
$ protoc -I protos --elixir_out=./lib protos/namespace/*.proto
20+
21+
Options:
22+
--version Print version of protobuf-elixir
23+
"""
24+
end
25+
226
def main(_) do
327
# https://groups.google.com/forum/#!topic/elixir-lang-talk/T5enez_BBTI
428
:io.setopts(:standard_io, encoding: :latin1)

mix.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Protobuf.Mixfile do
22
use Mix.Project
33

4-
@version "0.7.0"
4+
@version "0.7.1"
55

66
def project do
77
[
@@ -29,7 +29,7 @@ defmodule Protobuf.Mixfile do
2929
end
3030

3131
defp escript do
32-
[main_module: Protobuf.Protoc.CLI, name: "protoc-gen-elixir", app: nil]
32+
[main_module: Protobuf.Protoc.CLI, name: "protoc-gen-elixir"]
3333
end
3434

3535
defp description do

0 commit comments

Comments
 (0)