lib/doggy/cli/mute.rb in doggy-2.0.32 vs lib/doggy/cli/mute.rb in doggy-2.0.33
- old
+ new
@@ -1,16 +1,21 @@
# encoding: utf-8
+require 'doggy/duration'
+
module Doggy
class CLI::Mute
def initialize(options, ids)
@options = options
@ids = ids
end
def run
monitors = @ids.map { |id| Doggy::Models::Monitor.find(id) }
- monitors.each { |monitor| monitor.toggle_mute!('mute') }
+ body = {}
+ if @options['duration']
+ body[:end] = Time.now.utc.to_i + Duration.parse(@options['duration']).to_i
+ end
+ monitors.each { |monitor| monitor.toggle_mute!('mute', JSON.dump(body)) }
end
end
end
-