Sha256: 94a33b23fa0c5fae964f5c36e2f7c84b139a296b05e9739403998d263c8f5c1f

Contents?: true

Size: 766 Bytes

Versions: 20

Compression:

Stored size: 766 Bytes

Contents

# frozen_string_literal: true
require 'shopify_cli'
require 'optparse'

module ShopifyCli
  class Options
    include SmartProperties

    attr_reader :flags, :subcommand, :help

    def initialize
      @flags = {}
      @help = false
    end

    def parse(options_block, args)
      @args = args
      if options_block.respond_to?(:call) && args
        parse_flags(options_block)
      else
        parser.permute!(@args)
      end
      @args
    end

    def parse_flags(block)
      block.call(parser, @flags)
      parser.permute!(@args)
    end

    def parser
      @parser ||= begin
        opt = OptionParser.new
        opt.on('--help', '-h', Context.message('core.options.help_text')) do |v|
          @help = v
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
shopify-cli-1.6.0 lib/shopify-cli/options.rb
shopify-cli-1.5.0 lib/shopify-cli/options.rb
shopify-cli-1.4.1 lib/shopify-cli/options.rb
shopify-cli-1.4.0 lib/shopify-cli/options.rb
shopify-cli-1.3.1 lib/shopify-cli/options.rb
shopify-cli-1.3.0 lib/shopify-cli/options.rb
shopify-cli-1.2.0 lib/shopify-cli/options.rb
shopify-cli-1.1.2 lib/shopify-cli/options.rb
shopify-cli-1.1.1 lib/shopify-cli/options.rb
shopify-cli-1.1.0 lib/shopify-cli/options.rb
shopify-cli-1.0.5 lib/shopify-cli/options.rb
shopify-cli-1.0.4 lib/shopify-cli/options.rb
shopify-cli-1.0.3 lib/shopify-cli/options.rb
shopify-cli-1.0.2 lib/shopify-cli/options.rb
shopify-cli-1.0.1 lib/shopify-cli/options.rb
shopify-cli-1.0.0 lib/shopify-cli/options.rb
shopify-cli-0.9.3 lib/shopify-cli/options.rb
shopify-cli-0.9.2 lib/shopify-cli/options.rb
shopify-cli-0.9.1 lib/shopify-cli/options.rb
shopify-cli-0.9.0 lib/shopify-cli/options.rb