Sha256: d1b1a94e7ab7b8ad44991bd0b5cd50707925c7188d8733693daa181cb2b4e623

Contents?: true

Size: 776 Bytes

Versions: 3

Compression:

Stored size: 776 Bytes

Contents

# frozen_string_literal: true

module I18nJSON
  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-json-0.0.3 lib/i18n-json/cli/command.rb
i18n-json-0.0.2 lib/i18n-json/cli/command.rb
i18n-json-0.0.1 lib/i18n-json/cli/command.rb