Class: Begin::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/begin/cli.rb

Overview

The CLI interface for the application.

Instance Method Summary collapse

Instance Method Details

#install(path) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/begin/cli.rb', line 34

def install(path)
  repo = repository
  template_name = repo.template_name path
  Output.action "Installing template '#{template_name}' from '#{path}'"
  repo.install path, template_name
  Output.success "Template '#{template_name}' successfully installed"
end

#listObject



29
30
31
# File 'lib/begin/cli.rb', line 29

def list
  repository.each { |x| Output.info(x) }
end

#new(template) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/begin/cli.rb', line 16

def new(template)
  template_impl = repository.template template
  context = if options[:yaml]
              YAML.load_file(options[:yaml])
            else
              Input.prompt_user_for_tag_values(template_impl.config.tags)
            end
  Output.action "Running template '#{template}'"
  template_impl.run Dir.getwd, context
  Output.success "Template '#{template}' successfully run"
end

#uninstall(template) ⇒ Object



43
44
45
46
47
48
# File 'lib/begin/cli.rb', line 43

def uninstall(template)
  template_impl = repository.template template
  Output.action "Uninstalling template #{template}"
  template_impl.uninstall
  Output.success "Template '#{template}' successfully uninstalled"
end

#update(template = nil) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/begin/cli.rb', line 51

def update(template = nil)
  if template
    template_impl = repository.template template
    Output.action "Updating template #{template}"
    template_impl.update
  else
    repository.each do |x|
      Output.action "Updating template #{x}"
      repository.template(x).update
    end
  end
end

#versionObject



65
66
67
# File 'lib/begin/cli.rb', line 65

def version
  Output.info VERSION
end