class TheFox::Timr::Command::ResetCommand

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

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

Constants

MAN_PATH

Path to man page.

Public Class Methods

new(argv = Array.new) click to toggle source
# 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 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

Private Instance Methods

help() click to toggle source
# File lib/timr/command/reset_command.rb, line 63
def help
        puts 'usage: timr reset [-s|--stack]'
        puts
        puts 'Options'
        puts '    -s, --stack    Clean the Stack.'
        puts
end