class TheFox::Timr::Command::StatusCommand

Print [Stack](TheFox::Timr::Model::Stack) Status.

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

Constants

MAN_PATH

Path to man page.

Public Class Methods

new(argv = Array.new) click to toggle source
# File lib/timr/command/status_command.rb, line 18
def initialize(argv = Array.new)
        super()
        
        @help_opt = false
        
        @verbose_opt = false
        @full_opt = false
        @reverse_opt = false
        
        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 '-f', '--full'
                        @full_opt = true
                when '-r', '--reverse'
                        @reverse_opt = true
                else
                        raise StatusCommandError, "Unknown argument '#{arg}'. See 'timr stop --help'."
                end
        end
end

Public Instance Methods

run() click to toggle source

See BasicCommand#run.

# File lib/timr/command/status_command.rb, line 48
def run
        if @help_opt
                help
                return
        end
        
        @timr = Timr.new(@cwd)
        
        if @full_opt
                print_full_table
        else
                print_small_table
        end
end

Private Instance Methods

get_tracks() click to toggle source
# File lib/timr/command/status_command.rb, line 160
def get_tracks
        if @reverse_opt
                @timr.stack.tracks.reverse
        else
                @timr.stack.tracks
        end
end
help() click to toggle source
# File lib/timr/command/status_command.rb, line 168
def help
        puts 'usage: timr status [-h|--help] [-f|--full] [-r|--reverse]'
        puts
        puts 'Options'
        puts '    -v, --verbose    Show more columns in table view.'
        puts '    -f, --full       Show full status.'
        puts '    -r, --reverse    Reverse the list.'
        puts
        puts 'Columns'
        puts '    S        Status'
        puts '    START    Track Start Date'
        puts '    END      Track End Date'
        puts '    DUR      Track Duration'
        puts '    EST      Task Estimation'
        puts '    ETR      Task Estimated Time Remaining'
        puts '    ETR%     Task Estimated Time Remaining in percent.'
        puts '    TASK     Task ID'
        puts '    TRACK    Track ID and Title.'
        puts
        puts 'Status'
        puts '    R    Running'
        puts '    S    Stopped'
        puts '    U    Unknown'
        puts '    -    Not started yet.'
        puts
end
print_full_table() click to toggle source
print_no_tracks() click to toggle source
print_small_table() click to toggle source