Skip to content

Commit 68561ce

Browse files
committed
Merge branch 'main' of https://github.com/hotln/nexus
2 parents 9117048 + b66dfd1 commit 68561ce

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

examples/escript/example.ex

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,20 @@ defmodule Escript.Example do
1414
"""
1515

1616
use Nexus.CLI, otp_app: :nexus_cli
17+
alias Nexus.CLI.Helpers
1718

1819
defcommand :echo do
1920
description "Command that receives a string as argument and prints it."
2021

2122
value :string, required: true
2223
end
2324

25+
defcommand :greet do
26+
description "Greets the user by asking his name"
27+
28+
29+
end
30+
2431
defcommand :fizzbuzz do
2532
description "Fizz bUZZ"
2633

@@ -51,6 +58,12 @@ defmodule Escript.Example do
5158
IO.puts(value)
5259
end
5360

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+
5467
def handle_input(:fizzbuzz, %{value: value}) when is_integer(value) do
5568
cond do
5669
rem(value, 3) == 0 and rem(value, 5) == 0 -> IO.puts("fizzbuzz")

0 commit comments

Comments
 (0)