Class: AmberExtensionGenerator::CLI::Args

Inherits:
Object
  • Object
show all
Defined in:
lib/amber_extension_generator/cli/args.rb

Overview

Parses and wraps all provided CLI arguments.

Constant Summary collapse

<<~DOC
  Usage:
    amber_extension_generator GEM_PATH
    amber_extension_generator [options]

DOC

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#gem_pathPathname

Returns Path of the newly generated gem.

Returns:

  • (Pathname)

    Path of the newly generated gem



44
45
46
# File 'lib/amber_extension_generator/cli/args.rb', line 44

def gem_path
  @gem_path
end

Class Method Details

.parse(argv = ::ARGV) ⇒ self

Parameters:

  • argv (Array<String>) (defaults to: ::ARGV)

Returns:

  • (self)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/amber_extension_generator/cli/args.rb', line 19

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