Skip to content

Commit d8139b9

Browse files
author
av
committed
Added --version option. Fixes #6
1 parent f61c40b commit d8139b9

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

lib/smppsend.ex

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ defmodule SMPPSend do
55

66
@switches [
77
help: :boolean,
8+
version: :boolean,
89

910
bind_mode: :string,
1011
host: :string,
@@ -88,6 +89,7 @@ defmodule SMPPSend do
8889
&validate_unknown/1,
8990
&set_defaults/1,
9091
&show_help/1,
92+
&show_version/1,
9193
&validate_missing/1,
9294
&decode_hex_string/1,
9395
&convert_to_ucs2/1,
@@ -146,6 +148,16 @@ defmodule SMPPSend do
146148
end
147149
end
148150

151+
defp show_version(opts) do
152+
if opts[:version] do
153+
IO.puts(SMPPSend.Version.version)
154+
:exit
155+
else
156+
{:ok, opts}
157+
end
158+
end
159+
160+
149161
defp decode_hex_string(opts) do
150162
if opts[:binary] do
151163
case SMPPSend.OptionHelpers.decode_hex_string(opts, :short_message) do

lib/smppsend/usage.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Usage: C<smppsend> g<OPTIONS>
77
Available options are:
88
99
--help Show this help
10+
--version Show version
1011
1112
--bind-mode y<mode> Bind mode, one of the following: y<tx>(transmitter), y<rx>(receiver), y<trx>(transceiver)
1213
@@ -20,7 +21,7 @@ Available options are:
2021
--udh Prepend short_message with UDH. This option is incompatible with --split-max-bytes option
2122
2223
--ucs2 Convert short_message field and message_payload TLV from UTF8 to UCS2 before sending submit_sm PDUs
23-
24+
2425
--binary Decode short_message field and message_payload TLV from raw hex representation (e.g. input `003100320033` to see `123` in a UCS2 message)
2526
2627
--wait-dlrs y<timeout> Wait for for delivery reports for all sent submit_sm PDUs or exit with failure after y<timeout> ms

lib/smppsend/version.ex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
defmodule SMPPSend.Version do
2+
def version do
3+
Application.spec(:smppsend)
4+
|> Keyword.get(:vsn)
5+
|> to_string
6+
end
7+
end

test/smppsend/version_test.exs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
defmodule SMPPSend.VersionTest do
2+
use ExUnit.Case
3+
4+
test "version" do
5+
assert {:ok, _} = Version.parse(SMPPSend.Version.version)
6+
end
7+
end

0 commit comments

Comments
 (0)