class TheFox::Timr::Command::ResetCommand

Remove current running Track. Paused commands will not be deleted.

Man page: timr-reset(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/reset_command.rb, line 18
def initialize(argv = Array.new)
    super()
    
    @help_opt = false
    @stack_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 '-s', '--stack'
            @stack_opt = true
        else
            raise ResetCommandError, "Unknown argument '#{arg}'. See 'timr report --help'."
        end
    end
end

Public Instance Methods

run() click to toggle source

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

# File lib/timr/command/reset_command.rb, line 41
def run
    if @help_opt
        help
        return
    end
    
    @timr = Timr.new(@cwd)
    
    track = @timr.stack.current_track
    if track && track.running?
        puts '--- RESET ---'
        puts track.to_compact_str
        puts
    end
    
    @timr.reset({:stack => @stack_opt})
    
    puts @timr.stack
end