Module: Archive::Tar::Minitar::Command

Defined in:
lib/gems/archive-tar-minitar-0.5.2/lib/archive/tar/minitar/command.rb

Defined Under Namespace

Classes: CommandCreate, CommandExtract, CommandHelp, CommandList, CommandPattern, ProgressBar

Class Method Summary collapse

Class Method Details

.run(argv, input = $stdin, output = $stdout, error = $stderr) ⇒ Object

CommandPattern << CommandDelete



779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
# File 'lib/gems/archive-tar-minitar-0.5.2/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