Code Coverage
 
Lines
Covered
53.33% covered (warning)
53.33%
24 / 45
1
module TheFox
1
module Timr
1
module Command
# Continue the previous paused [Track](rdoc-ref:TheFox::Timr::Model::Track).
#
# Man page: [timr-continue(1)](../../../../man/timr-continue.1.html)
1
class ContinueCommand < BasicCommand
1
include TheFox::Timr::Helper
1
include TheFox::Timr::Error
# Path to man page.
1
MAN_PATH = 'man/timr-continue.1'
1
def initialize(argv = Array.new)
5
super()
5
@help_opt = false
5
@date_opt = nil
5
@time_opt = nil
5
loop_c = 0 # Limit the loop.
5
while loop_c < 1024 && argv.length > 0
4
loop_c += 1
4
arg = argv.shift
4
case arg
when '-h', '--help'
1
@help_opt = true
when '-d', '--date'
1
@date_opt = argv.shift
when '-t', '--time'
1
@time_opt = argv.shift
else
1
raise ContinueCommandError, "Unknown argument '#{arg}'. See 'timr continue --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
options = {
:date => @date_opt,
:time => @time_opt,
}
0
track = @timr.continue(options)
0
unless track
0
puts 'No running Track to continue.'
0
return
end
0
puts '--- CONTINUED ---'
0
puts track.to_compact_str
0
puts @timr.stack
end
1
private
1
def help
0
puts 'usage: timr continue [-d|--date <date>] [-t|--time <time>]'
0
puts ' or: timr continue [-h|--help]'
0
puts
0
puts 'Track Options'
0
puts ' -d, --date <date> Track Start Date'
0
puts ' -t, --time <time> Track Start Time'
0
puts
0
HelpCommand.print_datetime_help
0
puts
end
end # class ContinueCommand
end # module Command
end # module Timr
end # module TheFox