Class: CodelessCode::Cli

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(command_name = $PROGRAM_NAME, args = ARGV) ⇒ 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

#callObject


30
31
32
33
34
35
36
37
38
# 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, options.help)
  exit 1
ensure
  user_io&.close
end