class TheFox::Timr::Command::TrackCommand

Man page: timr-track(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/track_command.rb, line 21
def initialize(argv = Array.new)
    super()
    
    @help_opt = false
    @show_opt = false
    @add_opt = false
    @remove_opt = false
    @set_opt = false
    
    @verbose_opt = false
    @tracks_opt = Set.new
    @task_opt = false
    @task_id_opt = nil
    
    @message_opt = nil
    @start_date_opt = nil
    @start_time_opt = nil
    @end_date_opt = nil
    @end_time_opt = nil
    @billed_opt = nil
    @unbilled_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 '-v', '--verbose'
            @verbose_opt = true
        when '-t', '--task'
            if @set_opt
                @task_id_opt = argv.shift
            else
                @task_opt = true
            end
        
        when '-m', '--message'
            @message_opt = argv.shift
        when '--sd', '--start-date'
            @start_date_opt = argv.shift
        when '--st', '--start-time'
            @start_time_opt = argv.shift
        when '--ed', '--end-date'
            @end_date_opt = argv.shift
        when '--et', '--end-time'
            @end_time_opt = argv.shift
        when '-b', '--billed'
            @billed_opt = true
        when '--unbilled'
            @unbilled_opt = true
        
        when 'show'
            @show_opt = true
        when 'add'
            @add_opt = true
        when 'remove'
            @remove_opt = true
        when 'set'
            @set_opt = true
        
        else
            @tracks_opt << arg
        end
    end
    
    if @billed_opt && @unbilled_opt
        raise TrackCommandError, 'Cannot use --billed and --unbilled.'
    end
end

Public Instance Methods

run() click to toggle source

See TheFox::Timr::Command::BasicCommand#run.

# File lib/timr/command/track_command.rb, line 96
def run
    if @help_opt
        help
        return
    end
    
    @timr = Timr.new(@cwd)
    @timr.load_all_tracks
    
    if @task_opt
        run_task_command
    elsif @add_opt
        run_add
    elsif @remove_opt
        run_remove
    elsif @set_opt
        run_set
    else
        run_show
    end
end