Class: I18nJS::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n-js/cli.rb,
lib/i18n-js/cli/ui.rb,
lib/i18n-js/cli/command.rb,
lib/i18n-js/cli/init_command.rb,
lib/i18n-js/cli/check_command.rb,
lib/i18n-js/cli/export_command.rb,
lib/i18n-js/cli/plugins_command.rb,
lib/i18n-js/cli/version_command.rb,
lib/i18n-js/cli/lint_scripts_command.rb,
lib/i18n-js/cli/lint_translations_command.rb

Defined Under Namespace

Classes: CheckCommand, Command, ExportCommand, InitCommand, LintScriptsCommand, LintTranslationsCommand, PluginsCommand, UI, VersionCommand

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv:, stdout:, stderr:, colored: stdout.tty?) ⇒ CLI

Returns a new instance of CLI.



18
19
20
21
# File 'lib/i18n-js/cli.rb', line 18

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

Instance Attribute Details

#uiObject (readonly)

Returns the value of attribute ui.



16
17
18
# File 'lib/i18n-js/cli.rb', line 16

def ui
  @ui
end

Instance Method Details

#callObject



23
24
25
26
27
28
29
30
# File 'lib/i18n-js/cli.rb', line 23

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

  ui.fail_with(root_help) unless command

  command.call
end