Class: Prepd::Command
- Inherits:
-
Object
- Object
- Prepd::Command
- Defined in:
- lib/prepd/cli/commands.rb
Class Method Summary collapse
- .build(name = ARGV.shift) ⇒ Object
- .config ⇒ Object
- .list(type = ARGV.shift) ⇒ Object
- .new(type = ARGV.shift, name = ARGV.shift, *args) ⇒ Object
- .rm(name = nil) ⇒ Object
-
.setup ⇒ Object
Setup a new installation of prepd on a workstation.
- .show(name = nil) ⇒ Object
- .up(name = ARGV.shift) ⇒ Object
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..join("\n") unless cr.valid? cr.create nil 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..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..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..join('. ') end |
.setup ⇒ Object
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..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 |