lib/doggy/cli/edit.rb in doggy-2.0.15 vs lib/doggy/cli/edit.rb in doggy-2.0.17
- old
+ new
@@ -46,9 +46,17 @@
resources += Doggy::Models::Screen.all_local
if @param =~ /^[0-9]+$/ then
id = @param.to_i
return resources.find { |res| res.id == id }
+ elsif @param =~ /^http/ then
+ id = case @param
+ when /com\/dash/ then Integer(@param[/dash\/(\d+)/i, 1])
+ when /com\/screen/ then Integer(@param[/screen\/(\d+)/i, 1])
+ when /com\/monitors/ then Integer(@param[/monitors#(\d+)/i, 1])
+ else raise StandardError.new('Unknown resource type, cannot edit.')
+ end
+ return resources.find { |res| res.id == id }
else
full_path = File.expand_path(@param, Doggy.object_root)
return resources.find { |res| res.path == full_path }
end
end