Module: Formatron::Completion

Defined in:
lib/formatron/completion.rb

Overview

command completion utilities

Defined Under Namespace

Classes: Template

Class Method Summary collapse

Class Method Details

.script(command, subcommands) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/formatron/completion.rb', line 14

def self.script(command, subcommands)
  template = File.join(
    File.dirname(File.expand_path(__FILE__)),
    'completion',
    'completion.sh.erb'
  )
  erb = ERB.new File.read(template)
  erb.filename = template
  erb_template = erb.def_class Template, 'render()'
  erb_template.new(command, subcommands).render
end