-
Notifications
You must be signed in to change notification settings - Fork 8
Basics
mosop edited this page Jul 25, 2021
·
7 revisions
To define a command, define a class and inherit Cli::Command.
class Smile < Cli::Command
endTo run a command, define a #run method in your command class and call the .run method.
class Smile < Cli::Command
def run
puts ":)"
end
end
Smile.runThis prints:
:)
To pass arguments to a command, call .run with arguments.
class Smile < Cli::Command
def run
puts "#{args[0]} :)"
end
end
Smile.run %w(hello)This prints:
hello :)