Class: RoboPigeon::Extensions::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/robopigeon/extend/cli.rb

Class Method Summary collapse

Class Method Details

.invoke(args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/robopigeon/extend/cli.rb', line 6

def invoke(args)
  template = 'default'
  path = FileUtils.pwd
  optparse = OptionParser.new do |opts|
    opts.banner = 'Usage: robopigeon new [options] name'

    opts.on('-d', '--default', 'use the default template') do
      template = 'default'
    end

    opts.on('-h', '--help', 'Show help message') do
      puts opts
      exit 1
    end

    opts.on('-p', '--path [path]', 'path to where the gem should be created') do |selected_path|
      path = selected_path
    end
  end

  args.shift
  options = optparse.parse(args)
  name = options.shift

  RoboPigeon::Extensions::Template.render(name, path, template)
end