Class: CodelessCode::Cli
- Inherits:
-
Object
- Object
- CodelessCode::Cli
- Defined in:
- lib/codeless_code/cli.rb
Overview
Parse command-line parameters and dispatch them to the user’s chosen “command.”
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(command_name = $PROGRAM_NAME, args = ARGV) ⇒ Cli
constructor
A new instance of Cli.
Constructor Details
#initialize(command_name = $PROGRAM_NAME, args = ARGV) ⇒ Cli
Returns a new instance of Cli.
25 26 27 28 |
# File 'lib/codeless_code/cli.rb', line 25 def initialize(command_name = $PROGRAM_NAME, args = ARGV) @command_name = command_name @args = args end |
Instance Method Details
#call ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/codeless_code/cli.rb', line 30 def call user_io = io_open call_io(user_io) rescue Slop::Error => err warn format("%s\n\n%s", err, .help) ensure user_io&.close end |