Protect accessory cli from missing accessory

This commit is contained in:
David Heinemeier Hansson
2023-01-27 16:12:18 +01:00
parent f58e5e0935
commit 407e1cc028
2 changed files with 93 additions and 62 deletions

View File

@@ -49,7 +49,7 @@ class Mrsk::Commander
end
def accessory_names
config.accessories.collect(&:name)
config.accessories&.collect(&:name) || []
end
@@ -74,7 +74,7 @@ class Mrsk::Commander
end
def accessory(name)
(@accessories ||= {})[name] ||= Mrsk::Commands::Accessory.new(config, name: name)
config.accessories.detect { |a| a.name == name }
end