class TheFox::Timr::Command::PauseCommand

Pause the current running Track.

Man page: timr-pause(1)

Constants

MAN_PATH

Path to man page.

Public Class Methods

new(argv = Array.new) click to toggle source
Calls superclass method TheFox::Timr::Command::BasicCommand.new
# 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