Class: BrohamScript

Inherits:
Object
  • Object
show all
Defined in:
bin/broham,
bin/broham-yo,
bin/broham-get,
bin/broham-sup,
bin/broham-diss,
bin/broham-word,
bin/broham-hosts,
bin/broham-register,
bin/broham-yo_yo_yo,
bin/broham-unregister,
bin/broham-fuck_all_yall,
bin/broham-unregister_like,
bin/broham-register_as_next

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attrObject

Returns the value of attribute attr.



21
22
23
# File 'bin/broham', line 21

def attr
  @attr
end

#role_nameObject

Returns the value of attribute role_name.



21
22
23
# File 'bin/broham', line 21

def role_name
  @role_name
end

Instance Method Details

#commandObject



22
# File 'bin/broham', line 22

def command()   Settings.command ; end

#get_cmdObject



63
64
65
66
67
68
69
# File 'bin/broham', line 63

def get_cmd
  BrohamScript.get_commandline_predicates :role_name, :attr
  $stderr.puts %Q{Getting #{attr} for hosts like #{role_name}}
  Broham.hosts_like(role_name).map do |bro|
    $stdout.puts bro[attr]
  end
end

#hosts_cmdObject



26
27
28
29
30
# File 'bin/broham', line 26

def hosts_cmd
  BrohamScript.get_commandline_predicates :role_name
  $stderr.puts %Q{Listing hosts like #{role_name}}
  dump_table Broham.hosts_like(role_name)
end

#register_as_next_cmdObject



41
42
43
44
45
46
47
48
# File 'bin/broham', line 41

def register_as_next_cmd
  # Settings.define :set, :description => %Q{Any arg prefixed with "--set" will become an extra arg to register: 'broham-register foo --set-path=/path/to/foo' sets :path => '/path/to/foo' as an additional attribute}, :type => Hash
  broham_args = Settings[:set]||{}
  BrohamScript.get_commandline_predicates :role_name
  $stderr.puts %Q{Registering #{role_name} -- #{broham_args}}
  new_bro = Broham.register_as_next(role_name, broham_args)
  dump_table [new_bro]
end

#register_cmdObject



32
33
34
35
36
37
38
39
# File 'bin/broham', line 32

def register_cmd
  # Settings.define :set, :description => %Q{Any arg prefixed with "--set" will become an extra arg to register: 'broham-register foo --set-path=/path/to/foo' sets :path => '/path/to/foo' as an additional attribute}, :type => Hash
  broham_args = Settings[:set]||{}
  BrohamScript.get_commandline_predicates :role_name
  $stderr.puts %Q{Registering #{role_name} -- #{broham_args}}
  new_bro = Broham.register(role_name, broham_args)
  dump_table [new_bro]
end

#runObject



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'bin/broham', line 71

def run
  case Settings.command.to_s
  when 'hosts', 'sup'
    hosts_cmd
  when 'register', 'yo'
    register_cmd
  when 'unregister', 'diss'
    unregister_cmd
  when 'unregister_like', 'fuck_all_yall'
    unregister_like_cmd
  when 'register_as_next'
    register_as_next_cmd
  when 'get', 'word'
    get_cmd
  when ''
    Settings.die "Please use one of the commands listed above"
  else
    Settings.die "Don't know how to run command #{command}"
  end
end

#unregister_cmdObject



50
51
52
53
54
55
# File 'bin/broham', line 50

def unregister_cmd
  BrohamScript.get_commandline_predicates :role_name
  $stderr.puts %Q{Unregistering #{role_name}}
  dead_bro = Broham.unregister(role_name)
  dump_table [dead_bro]
end

#unregister_like_cmdObject



57
58
59
60
61
# File 'bin/broham', line 57

def unregister_like_cmd
  BrohamScript.get_commandline_predicates :role_name
  $stderr.puts %Q{Unregistering all hosts like #{role_name}}
  dump_table Broham.unregister_like role_name
end