File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -14,13 +14,20 @@ defmodule Escript.Example do
14
14
"""
15
15
16
16
use Nexus.CLI , otp_app: :nexus_cli
17
+ alias Nexus.CLI.Helpers
17
18
18
19
defcommand :echo do
19
20
description "Command that receives a string as argument and prints it."
20
21
21
22
value :string , required: true
22
23
end
23
24
25
+ defcommand :greet do
26
+ description "Greets the user by asking his name"
27
+
28
+
29
+ end
30
+
24
31
defcommand :fizzbuzz do
25
32
description "Fizz bUZZ"
26
33
@@ -51,6 +58,12 @@ defmodule Escript.Example do
51
58
IO . puts ( value )
52
59
end
53
60
61
+ def handle_input ( :greet , _args ) do
62
+ name = Helpers . ask ( "Whats your name?" )
63
+ Helpers . say_success ( "Hello, #{ name } !" )
64
+ :ok
65
+ end
66
+
54
67
def handle_input ( :fizzbuzz , % { value: value } ) when is_integer ( value ) do
55
68
cond do
56
69
rem ( value , 3 ) == 0 and rem ( value , 5 ) == 0 -> IO . puts ( "fizzbuzz" )
You can’t perform that action at this time.
0 commit comments