class TheFox::Timr::Command::PauseCommand

Pause the current running [Track](TheFox::Timr::Model::Track).

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

Constants

MAN_PATH

Path to man page.

Public Class Methods

new(argv = Array.new) click to toggle source
# File lib/timr/command/pause_command.rb, line 17
def initialize(argv = Array.new)
        super()
        
        @help_opt = false
        
        @end_date_opt = nil
        @end_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 '--ed', '--end-date', '-d', '--date'
                        @end_date_opt = argv.shift
                when '--et', '--end-time', '-t', '--time'
                        @end_time_opt = argv.shift
                else
                        raise PauseCommandError, "Unknown argument '#{arg}'. See 'timr pause --help'."
                end
        end
end

Public Instance Methods

run() click to toggle source

See BasicCommand.

# File lib/timr/command/pause_command.rb, line 44
def run
        if @help_opt
                help
                return
        end
        
        @timr = Timr.new(@cwd)
        
        options = {
                :end_date => @end_date_opt,
                :end_time => @end_time_opt,
        }
        
        track = @timr.pause(options)
        unless track
                puts 'No running Track to pause.'
                return
        end
        
        puts '--- PAUSED ---'
        puts track.to_compact_str
        puts @timr.stack
end

Private Instance Methods

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