-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwelcome_command.cr
More file actions
30 lines (25 loc) · 927 Bytes
/
welcome_command.cr
File metadata and controls
30 lines (25 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class WelcomeCommand < Cling::Command
def setup : Nil
@name = "welcome"
@summary = @description = "sends a friendly welcome message"
add_argument "name", description: "the name of the person to greet", required: true
add_option 'h', "help", description: "sends help information"
# this will inherit the header and footer properties
@inherit_borders = true
# this will NOT inherit the parent flag options
@inherit_options = false
# this will inherit the input, output and error IO streams
@inherit_streams = true
end
def pre_run(arguments : Cling::Arguments, options : Cling::Options) : Bool
if options.has? "help"
puts help_template # generated using Cling::Formatter
false
else
true
end
end
def run(arguments : Cling::Arguments, options : Cling::Options) : Nil
stdout.puts "Welcome to the CLI world, #{arguments.get("name")}!"
end
end