Code Coverage
 
Lines
Covered
57.89% covered (warning)
57.89%
22 / 38
1
require 'set'
1
module TheFox
1
module Timr
1
module Command
# Remove current running Track. Paused commands will not be deleted.
#
# Man page: [timr-reset(1)](../../../../man/timr-reset.1.html)
1
class ResetCommand < BasicCommand
1
include TheFox::Timr::Error
# Path to man page.
1
MAN_PATH = 'man/timr-reset.1'
1
def initialize(argv = Array.new)
4
super()
4
@help_opt = false
4
@stack_opt = false
4
loop_c = 0 # Limit the loop.
4
while loop_c < 1024 && argv.length > 0
3
loop_c += 1
3
arg = argv.shift
3
case arg
when '-h', '--help'
1
@help_opt = true
when '-s', '--stack'
1
@stack_opt = true
else
1
raise ResetCommandError, "Unknown argument '#{arg}'. See 'timr report --help'."
end
end
end
# See BasicCommand#run.
1
def run
0
if @help_opt
0
help
0
return
end
0
@timr = Timr.new(@cwd)
0
track = @timr.stack.current_track
0
if track && track.running?
0
puts '--- RESET ---'
0
puts track.to_compact_str
0
puts
end
0
@timr.reset({:stack => @stack_opt})
0
puts @timr.stack
end
1
private
1
def help
0
puts 'usage: timr reset [-s|--stack]'
0
puts
0
puts 'Options'
0
puts ' -s, --stack Clean the Stack.'
0
puts
end
end # class TrackCommand
end # module Command
end # module Timr
end # module TheFox