All boot/remove for all accessories

This commit is contained in:
David Heinemeier Hansson
2023-01-23 10:38:03 +01:00
parent 699f271e6e
commit 78e50f23cd
2 changed files with 21 additions and 9 deletions

View File

@@ -1,12 +1,16 @@
require "mrsk/cli/base"
class Mrsk::Cli::Accessory < Mrsk::Cli::Base
desc "boot [NAME]", "Boot accessory service on host"
desc "boot [NAME]", "Boot accessory service on host (use NAME=all to boot all accessories)"
def boot(name)
invoke :upload, [ name ]
if name == "all"
MRSK.accessory_names.each { |accessory_name| boot(accessory_name) }
else
upload(name)
accessory = MRSK.accessory(name)
on(accessory.host) { execute *accessory.run }
accessory = MRSK.accessory(name)
on(accessory.host) { execute *accessory.run }
end
end
desc "upload [NAME]", "Upload accessory files to host"
@@ -77,12 +81,16 @@ class Mrsk::Cli::Accessory < Mrsk::Cli::Base
end
end
desc "remove [NAME]", "Remove accessory container and image from host"
desc "remove [NAME]", "Remove accessory container and image from host (use NAME=all to boot all accessories)"
def remove(name)
invoke :stop, [ name ]
invoke :remove_container, [ name ]
invoke :remove_image, [ name ]
invoke :remove_files, [ name ]
if name == "all"
MRSK.accessory_names.each { |accessory_name| remove(accessory_name) }
else
stop(name)
remove_container(name)
remove_image(name)
remove_files(name)
end
end
desc "remove_container [NAME]", "Remove accessory container from host"

View File

@@ -48,6 +48,10 @@ class Mrsk::Commander
specific_hosts || config.accessories.collect(&:host)
end
def accessory_names
config.accessories.collect(&:name)
end
def app
@app ||= Mrsk::Commands::App.new(config)