class TheFox::Timr::Command::ContinueCommand

Continue the previous paused [Track](TheFox::Timr::Model::Track).

Man page: [timr-continue(1)](../../../../man/timr-continue.1.html)

Constants

MAN_PATH

Path to man page.

Public Class Methods

new(argv = Array.new) click to toggle source
# File lib/timr/command/continue_command.rb, line 17
def initialize(argv = Array.new)
        super()
        
        @help_opt = false
        
        @date_opt = nil
        @time_opt = nil
        
        loop_c = 0 # Limit the loop.
        while loop_c < 1024 && argv.length > 0
                loop_c += 1
                arg = argv.shift
                
                case arg
                when '-h', '--help'
                        @help_opt = true
                when '-d', '--date'
                        @date_opt = argv.shift
                when '-t', '--time'
                        @time_opt = argv.shift
                else
                        raise ContinueCommandError, "Unknown argument '#{arg}'. See 'timr continue --help'."
                end
        end
end

Public Instance Methods

run() click to toggle source

See BasicCommand#run.

# File lib/timr/command/continue_command.rb, line 44
def run
        if @help_opt
                help
                return
        end
        
        @timr = Timr.new(@cwd)
        
        options = {
                :date => @date_opt,
                :time => @time_opt,
        }
        
        track = @timr.continue(options)
        unless track
                puts 'No running Track to continue.'
                return
        end
        
        puts '--- CONTINUED ---'
        puts track.to_compact_str
        puts @timr.stack
end

Private Instance Methods

help() click to toggle source
# File lib/timr/command/continue_command.rb, line 70
def help
        puts 'usage: timr continue [-d|--date <date>] [-t|--time <time>]'
        puts '   or: timr continue [-h|--help]'
        puts
        puts 'Track Options'
        puts '    -d, --date <date>    Track Start Date'
        puts '    -t, --time <time>    Track Start Time'
        puts
        HelpCommand.print_datetime_help
        puts
end