Sha256: 7fdc53a8d8a354d97e7fafb1e49298d1c31560ccb7e1860b581a3893260f31b4

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require 'pathname'

module ::AmberExtensionGenerator
  module CLI
    # Parses and wraps all provided CLI arguments.
    class Args
      BANNER = <<~DOC
        Usage:
          amber_extension_generator GEM_PATH
          amber_extension_generator [options]

      DOC

      class << self
        # @param argv [Array<String>]
        # @return [self]
        def parse(argv = ::ARGV)
          args = new

          opt_parser = ::OptionParser.new do |opts|
            opts.banner = BANNER

            opts.on('-v', '--version', 'Show the version of the gem') do |_val|
              puts VERSION
              exit
            end

            opts.on('-h', '--help', 'Show this help') do |_val|
              puts opts
              exit
            end
          end

          args.gem_path = ::Pathname.new(::File.expand_path(argv.first))
          opt_parser.parse(argv)

          args
        end
      end

      # @return [Pathname] Path of the newly generated gem
      attr_accessor :gem_path
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
amber_extension_generator-1.0.0 lib/amber_extension_generator/cli/args.rb
amber_extension_generator-0.0.5 lib/amber_extension_generator/cli/args.rb