Sha256: d148b0013637cbc9d913e1ec4af6628f9022b96526f6c5b93e7533d048377789

Contents?: true

Size: 766 Bytes

Versions: 57

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

57 entries across 57 versions & 1 rubygems

Version Path
shopify-cli-2.36.0 lib/shopify_cli/options.rb
shopify-cli-2.35.0 lib/shopify_cli/options.rb
shopify-cli-2.34.0 lib/shopify_cli/options.rb
shopify-cli-2.33.1 lib/shopify_cli/options.rb
shopify-cli-2.33.0 lib/shopify_cli/options.rb
shopify-cli-2.32.1 lib/shopify_cli/options.rb
shopify-cli-2.32.0 lib/shopify_cli/options.rb
shopify-cli-2.31.0 lib/shopify_cli/options.rb
shopify-cli-2.30.0 lib/shopify_cli/options.rb
shopify-cli-2.29.0 lib/shopify_cli/options.rb
shopify-cli-2.28.0 lib/shopify_cli/options.rb
shopify-cli-2.27.0 lib/shopify_cli/options.rb
shopify-cli-2.26.0 lib/shopify_cli/options.rb
shopify-cli-2.25.0 lib/shopify_cli/options.rb
shopify-cli-2.24.0 lib/shopify_cli/options.rb
shopify-cli-2.23.0 lib/shopify_cli/options.rb
shopify-cli-2.22.0 lib/shopify_cli/options.rb
shopify-cli-2.21.0 lib/shopify_cli/options.rb
shopify-cli-2.20.1 lib/shopify_cli/options.rb
shopify-cli-2.20.0 lib/shopify_cli/options.rb