Class: I18nJSON::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n-json/cli.rb,
lib/i18n-json/cli/ui.rb,
lib/i18n-json/cli/command.rb,
lib/i18n-json/cli/init_command.rb,
lib/i18n-json/cli/export_command.rb

Defined Under Namespace

Classes: Command, ExportCommand, InitCommand, UI

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv:, stdout:, stderr:) ⇒ CLI

Returns a new instance of CLI.



7
8
9
10
# File 'lib/i18n-json/cli.rb', line 7

def initialize(argv:, stdout:, stderr:)
  @argv = argv.dup
  @ui = UI.new(stdout: stdout, stderr: stderr)
end

Instance Attribute Details

#uiObject (readonly)

Returns the value of attribute ui.



5
6
7
# File 'lib/i18n-json/cli.rb', line 5

def ui
  @ui
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
# File 'lib/i18n-json/cli.rb', line 12

def call
  command_name = @argv.shift
  command = commands.find {|cmd| cmd.name == command_name }

  ui.fail_with(root_help) unless command

  command.call
end