Class: Houcho::CLI::Role

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

Constant Summary collapse

@@r =
Houcho::Role.new

Instance Method Summary collapse

Instance Method Details

#create(*args) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/houcho/cli/role.rb', line 12

def create(*args)
  Houcho::CLI::Main.empty_args(self, shell, __method__) if args.empty?
  @@r.create(args)
rescue Houcho::RoleExistenceException => e
  puts e.message
  exit!
end

#delete(*args) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/houcho/cli/role.rb', line 21

def delete(*args)
  Houcho::CLI::Main.empty_args(self, shell, __method__) if args.empty?
  @@r.delete(args)
rescue SQLite3::ConstraintException => e
  puts e.message
  exit!
end

#details(*args) ⇒ Object



38
39
40
41
# File 'lib/houcho/cli/role.rb', line 38

def details(*args)
  Houcho::CLI::Main.empty_args(self, shell, __method__) if args.empty?
  Houcho::CLI::Main.puts_details(@@r.details(args))
end

#exec(*args) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/houcho/cli/role.rb', line 51

def exec(*args)
  Houcho::CLI::Main.empty_args(self, shell, __method__) if args.empty?
  runner = Houcho::Spec::Runner.new

  begin
    exit! unless runner.execute_role(
      args,
      (options[:exclude_hosts] || []),
      options[:dry_run],
      true #output to console
    )
  rescue Houcho::SpecFileException => e
    puts e.message
    exit!
  end
end

#listObject



44
45
46
# File 'lib/houcho/cli/role.rb', line 44

def list
  puts @@r.list.join("\n")
end

#rename(exist_role, name) ⇒ Object



30
31
32
33
34
35
# File 'lib/houcho/cli/role.rb', line 30

def rename(exist_role, name)
  @@r.rename(exist_role, name)
rescue SQLite3::ConstraintException, SQLite3::SQLException => e
  puts e.message
  exit!
end