Class: Gunter::CLI

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

Overview

Gunter CLI using Thor

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/gunter/cli.rb', line 9

def self.exit_on_failure?
  true
end

Instance Method Details

#add(repo, name = nil) ⇒ Object



46
47
48
49
# File 'lib/gunter/cli.rb', line 46

def add(repo, name = nil)
  template = Gunter.model(:template).add(repo, name)
  Gunter.render(:text, :template_added, template)
end

#init(repo, location = nil) ⇒ Object



21
22
23
# File 'lib/gunter/cli.rb', line 21

def init(repo, location = nil)
  Gunter.model(:project).create(repo, location)
end

#listObject



27
28
29
30
31
32
33
# File 'lib/gunter/cli.rb', line 27

def list
  templates = Gunter.model(:template).all

  return Gunter.render(:json, :templates, templates) if options[:json]

  Gunter.render(:text, :templates, templates)
end

#search(term = '') ⇒ Object



37
38
39
40
41
42
43
# File 'lib/gunter/cli.rb', line 37

def search(term = '')
  templates = Gunter.model(:template).filter(term)

  return Gunter.render(:json, :templates, templates) if options[:json]

  Gunter.render(:text, :templates, templates)
end

#versionObject



16
17
18
# File 'lib/gunter/cli.rb', line 16

def version
  Gunter.render(:text, :gunter_version, Gunter.version)
end