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, line 779
  def self.run(argv, input = $stdin, output = $stdout, error = $stderr)
    ioe = {
      :input  => input,
      :output => output,
      :error  => error,
    }
    opts = { }

    if argv.include?("--version")
      output << <<-EOB
minitar #{Archive::Tar::Minitar::VERSION}
  Copyright 2004 Mauricio Julio Ferna'ndez Pradier and Austin Ziegler
  This is free software with ABSOLUTELY NO WARRANTY.

  see http://rubyforge.org/projects/ruwiki for more information
      EOB
    end

    if argv.include?("--verbose") or argv.include?("-V")
      opts[:verbose]  = true
      argv.delete("--verbose")
      argv.delete("-V")
    end

    if argv.include?("--progress") or argv.include?("-P")
      opts[:progress] = true
      opts[:verbose]  = false
      argv.delete("--progress")
      argv.delete("-P")
    end

    command = CommandPattern[(argv.shift or "").downcase]
    command ||= CommandPattern["help"]
    return command[argv, opts, ioe]
  end