Commits

seydar committed b7db959 Draft

tidying up support for elapsed time measurements

Comments (0)

Files changed (2)

lib/chitin/commands/builtins.rb

       def prompt
         "#{ENV['USER']}: #{short_pwd} % "
       end
+
+      # Get the elapsed time of the last command.
+      def last_elapsed
+        SESSION.last_elapsed
+      end
     end
     include Prompts
   

lib/chitin/session.rb

   
     attr_reader :config
     attr_reader :editor
+    attr_reader :last_elapsed
   
     def initialize(config=nil)
       @config  = config
           # if there's a quote, remove it. we'll add it back in later, but it ruins
           # searching so we need it removed for now.
           unquoted_line = ['"', '\''].include?(line[0, 1]) ? line[1..-1] : line
-  
-          #options  = Dir[unquoted_line + '*']
-          #options += 
 
           Dir[unquoted_line + '*'].map do |w|
             slash_it = File.directory?(w) and line[-1] != '/' and w[-1] != '/'
         next if val.empty?
   
         # a little bit of infrastructure for timing purposes
-        $timing = Time.now
+        timing = Time.now
 
         begin
           res = evaluate val
           puts "#{e.message} (#{e.class})"
           e.backtrace[1..-1].each {|l| puts "\t#{l}" }
           nil
+        ensure
+          @last_elapsed = Time.now - timing
         end
   
       end