Class: Prepd::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/prepd/cli/commands.rb

Class Method Summary collapse

Class Method Details

.build(name = ARGV.shift) ⇒ Object



24
25
26
27
28
29
# File 'lib/prepd/cli/commands.rb', line 24

def self.build(name = ARGV.shift)
  cr = Machine.new(name: name)
  return cr.errors.full_messages.join("\n") unless cr.valid?
  cr.create
  nil
end

.configObject



5
# File 'lib/prepd/cli/commands.rb', line 5

def self.config; Prepd.config; end

.list(type = ARGV.shift) ⇒ Object



7
8
9
10
# File 'lib/prepd/cli/commands.rb', line 7

def self.list(type = ARGV.shift)
  return 'invalid type' unless %w(clusters projects machines).include? type
  "Prepd::#{type.classify}".constantize.new.in_component_root { Dir.glob('*') }
end

.new(type = ARGV.shift, name = ARGV.shift, *args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/prepd/cli/commands.rb', line 12

def self.new(type = ARGV.shift, name = ARGV.shift, *args)
  cr = Creator.new(type: type)
  # TODO: this should display the appropriate help if name is not supplied
  return cr.errors.full_messages.join("\n") unless cr.valid?
  # return 'Must supply type' unless type
  # return 'Must supply APP_PATH' unless name
  obj = cr.klass.new(name: name)
  return obj.errors.full_messages.join("\n") unless obj.valid?
  obj.create
  nil
end

.rm(name = nil) ⇒ Object



41
42
43
44
45
# File 'lib/prepd/cli/commands.rb', line 41

def self.rm(name = nil)
  name ||= ARGV[0] || Dir.pwd.split('/').last
  return unless obj = klass.find_by(name: name)
  obj.destroy ? nil : obj.errors.full_messages.join('. ')
end

.setupObject

Setup a new installation of prepd on a workstation



50
51
52
53
54
# File 'lib/prepd/cli/commands.rb', line 50

def self.setup
  obj = Setup.new
  return obj.errors.full_messages.join("\n") unless obj.valid?
  obj.create
end

.show(name = nil) ⇒ Object



31
32
33
34
35
# File 'lib/prepd/cli/commands.rb', line 31

def self.show(name = nil)
  name ||= ARGV[0] || Dir.pwd.split('/').last
  return unless obj = klass.find_by(name: name)
  YAML.load(obj.to_yaml)
end

.up(name = ARGV.shift) ⇒ Object



37
38
39
# File 'lib/prepd/cli/commands.rb', line 37

def self.up(name = ARGV.shift)
  Cluster.new(name: name).up
end