Class: CodelessCode::Cli
- Inherits:
-
Object
- Object
- CodelessCode::Cli
- Defined in:
- lib/codeless_code/cli.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(command_name = $0, args = ARGV) ⇒ Cli
constructor
A new instance of Cli.
Constructor Details
#initialize(command_name = $0, args = ARGV) ⇒ Cli
Returns a new instance of Cli.
21 22 23 24 |
# File 'lib/codeless_code/cli.rb', line 21 def initialize(command_name = $0, args = ARGV) @command_name = command_name @args = args end |
Instance Method Details
#call ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/codeless_code/cli.rb', line 26 def call io = io_open if .key?(:help) (io || $stdout).puts .help elsif .key?(:version) (io || $stdout).puts version_str elsif .key?(:list_translations) Commands::ListTranslations.new(io: io).call else filter_fables(io) end rescue Slop::Error => e warn format("%s\n\n%s", e, .help) exit 1 ensure io&.close end |