Sha256: 2b810a6053f47c6f58a4e6e94f7af352fad8006128763946fa4f93a52b6006d0
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true require_relative "../i18n-js" require_relative "cli/command" require_relative "cli/ui" require_relative "cli/init_command" require_relative "cli/version_command" require_relative "cli/export_command" module I18nJS class CLI attr_reader :ui def initialize(argv:, stdout:, stderr:) @argv = argv.dup @ui = UI.new(stdout: stdout, stderr: stderr) end def call command_name = @argv.shift command = commands.find {|cmd| cmd.name == command_name } ui.fail_with(root_help) unless command command.call end private def command_classes [InitCommand, ExportCommand, VersionCommand] end private def commands command_classes.map do |command_class| command_class.new(argv: @argv, ui: ui) end end private def root_help commands_list = commands .map {|cmd| "- #{cmd.name}: #{cmd.description}" } .join("\n") <<~TEXT Usage: i18n COMMAND FLAGS Commands: #{commands_list} Run `i18n COMMAND --help` for more information on specific commands. TEXT end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
i18n-js-4.0.0.alpha3 | lib/i18n-js/cli.rb |
i18n-js-4.0.0.alpha2 | lib/i18n-js/cli.rb |