Sha256: 100391aef06e050dc08a6ca52b7ac607073ddaacc4b84147b3468b798ad30474

Contents?: true

Size: 774 Bytes

Versions: 3

Compression:

Stored size: 774 Bytes

Contents

# frozen_string_literal: true

module I18nJS
  class CLI
    class Command
      attr_reader :ui, :argv

      def self.command_name(name)
        define_method(:name) { name }
      end

      def self.description(description)
        define_method(:description) { description }
      end

      def self.parse(&block)
        define_method(:parse) do
          OptionParser
            .new {|opts| instance_exec(opts, &block) }
            .parse!(argv)
        end
      end

      def self.command(&block)
        define_method(:command, &block)
      end

      def initialize(argv:, ui:)
        @argv = argv.dup
        @ui = ui
      end

      def call
        parse
        command
      end

      def options
        @options ||= {}
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
i18n-js-4.0.0.alpha3 lib/i18n-js/cli/command.rb
i18n-js-4.0.0.alpha2 lib/i18n-js/cli/command.rb
i18n-js-4.0.0.alpha1 lib/i18n-js/cli/command.rb