module Archive::Tar::Minitar::Command

Public Class Methods

run(argv, input = $stdin, output = $stdout, error = $stderr) click to toggle source

CommandPattern << CommandAdd CommandPattern << CommandDelete

    # File lib/archive/tar/minitar/command.rb
779   def self.run(argv, input = $stdin, output = $stdout, error = $stderr)
780     ioe = {
781       :input  => input,
782       :output => output,
783       :error  => error,
784     }
785     opts = { }
786 
787     if argv.include?("--version")
788       output << <<-EOB
789 minitar #{Archive::Tar::Minitar::VERSION}
790   Copyright 2004 Mauricio Julio Ferna'ndez Pradier and Austin Ziegler
791   This is free software with ABSOLUTELY NO WARRANTY.
792 
793   see http://rubyforge.org/projects/ruwiki for more information
794       EOB
795     end
796 
797     if argv.include?("--verbose") or argv.include?("-V")
798       opts[:verbose]  = true
799       argv.delete("--verbose")
800       argv.delete("-V")
801     end
802 
803     if argv.include?("--progress") or argv.include?("-P")
804       opts[:progress] = true
805       opts[:verbose]  = false
806       argv.delete("--progress")
807       argv.delete("-P")
808     end
809 
810     command = CommandPattern[(argv.shift or "").downcase]
811     command ||= CommandPattern["help"]
812     return command[argv, opts, ioe]
813   end