Class: Appifier::CLI::Subcommands::Templates

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

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Templates

Returns a new instance of Templates.



8
9
10
11
12
# File 'lib/appifier/cli/templates.rb', line 8

def initialize(*args)
  super
  @output = Carioca::Registry.get.get_service name: :output
  @finisher = Carioca::Registry.get.get_service name: :finisher
end

Instance Method Details

#lint(template) ⇒ Object



70
71
72
73
74
75
76
77
78
# File 'lib/appifier/cli/templates.rb', line 70

def lint(template)
  begin
    Appifier::Components::Template::lint(template)
    @finisher.terminate exit_case: :quiet_exit
  rescue RuntimeError => e
    @output.error e.message
    @finisher.terminate exit_case: :error_exit
  end 
end

#lsObject



16
17
18
19
20
21
22
23
24
# File 'lib/appifier/cli/templates.rb', line 16

def ls
  begin
    Appifier::Components::Template::list
    @finisher.terminate exit_case: :quiet_exit
  rescue RuntimeError => e
    @output.error e.message
    @finisher.terminate exit_case: :error_exit
  end 
end

#rm(template) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/appifier/cli/templates.rb', line 28

def rm(template)
  begin 
    Appifier::Components::Template::rm(template)
    @finisher.terminate exit_case: :quiet_exit
  rescue RuntimeError => e
    @output.error e.message
    @finisher.terminate exit_case: :error_exit
  end 
end

#show(template) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/appifier/cli/templates.rb', line 40

def show(template)
  begin
    Appifier::Components::Template::show(template)
    temp = Appifier::Components::Template::new(template: template)
    if temp.readme?
      puts " "
      puts TTY::Markdown.parse_file(temp.readme_path)
    end

    @finisher.terminate exit_case: :quiet_exit
  rescue RuntimeError => e
    @output.error e.message
    @finisher.terminate exit_case: :error_exit
  end 
end

#treeview(template) ⇒ Object



58
59
60
61
62
63
64
65
66
# File 'lib/appifier/cli/templates.rb', line 58

def treeview(template)
  begin
    Appifier::Components::Template::treeview(template)
    @finisher.terminate exit_case: :quiet_exit
  rescue RuntimeError => e
    @output.error e.message
    @finisher.terminate exit_case: :error_exit
  end 
end