service del-environment
parent
1bc9181caa
commit
21e6943868
|
@ -184,7 +184,12 @@ commands.push "show", "Shows a service's configuration and state." do |args|
|
|||
end
|
||||
|
||||
commands.push "add-environment", "Creates a new (empty) environment." do |arg|
|
||||
Environment.new(args[9]).write ENVIRONMENTS_DIRECTORY
|
||||
if arg.size != 1
|
||||
STDERR.puts "usage: service add-environment <name>"
|
||||
exit 1
|
||||
end
|
||||
|
||||
Environment.new(arg[0]).write ENVIRONMENTS_DIRECTORY
|
||||
end
|
||||
|
||||
commands.push "list-environments", "Lists all currently defined environments.s", do |arg|
|
||||
|
@ -193,6 +198,30 @@ commands.push "list-environments", "Lists all currently defined environments.s",
|
|||
end
|
||||
end
|
||||
|
||||
commands.push "del-environment", "Removes an empty environment." do |arg|
|
||||
rvalue = 0
|
||||
|
||||
arg.each do |arg|
|
||||
environment = Environment.all.find &.name.==(arg)
|
||||
|
||||
if environment.nil?
|
||||
STDERR.puts "#{arg}: no such environment"
|
||||
rvalue = 2
|
||||
next
|
||||
end
|
||||
|
||||
if Service.all.select(&.environment.name.==(environment.name)).size > 0
|
||||
STDERR.puts "#{arg}: is not empty"
|
||||
rvalue = 1
|
||||
next
|
||||
end
|
||||
|
||||
environment.remove ENVIRONMENTS_DIRECTORY
|
||||
end
|
||||
|
||||
exit rvalue
|
||||
end
|
||||
|
||||
commands.push "help", "Prints this help message." do
|
||||
puts parser
|
||||
puts
|
||||
|
|
|
@ -70,6 +70,10 @@ class Environment
|
|||
File.write "#{dir}/#{@name}.spec", to_spec
|
||||
end
|
||||
|
||||
def remove(dir : String)
|
||||
File.delete "#{dir}/#{@name}.spec"
|
||||
end
|
||||
|
||||
def to_spec
|
||||
[
|
||||
"type: #{@type.to_s}"
|
||||
|
|
Loading…
Reference in New Issue