Class: Archive::Tar::Minitar::Command::CommandHelp

Inherits:
CommandPattern show all
Defined in:
lib/gems/archive-tar-minitar-0.5.2/lib/archive/tar/minitar/command.rb

Instance Method Summary collapse

Methods inherited from CommandPattern

<<, [], #[], add, command, command?, default_ioe

Instance Method Details

#call(args, opts = {}, ioe = {}) ⇒ Object



312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
# File 'lib/gems/archive-tar-minitar-0.5.2/lib/archive/tar/minitar/command.rb', line 312

def call(args, opts = {}, ioe = {})
  ioe = CommandPattern.default_ioe(ioe)

  help_on = args.shift

  if CommandPattern.command?(help_on)
    ioe[:output] << CommandPattern[help_on].help
  elsif help_on == "commands"
    ioe[:output] << <<-EOH
The commands known to minitar are:

minitar create          Creates a new tarfile.
minitar extract         Extracts files from a tarfile.
minitar list            Lists files in the tarfile.

All commands accept the options --verbose and --progress, which are
mutually exclusive. In "minitar list", --progress means the same as
--verbose.

  --verbose, -V     Performs the requested command verbosely.
  --progress, -P    Shows a progress bar, if appropriate, for the action
                being performed.

    EOH
  else
    ioe[:output] << "Unknown command: #{help_on}\n" unless help_on.nil? or help_on.empty?
    ioe[:output] << self.help
  end

  0
end

#helpObject



344
345
346
347
348
349
350
351
352
353
# File 'lib/gems/archive-tar-minitar-0.5.2/lib/archive/tar/minitar/command.rb', line 344

def help
  help = <<-EOH
This is a basic help message containing pointers to more information on
how to use this command-line tool. Try:

minitar help commands       list all 'minitar' commands
minitar help <COMMAND>      show help on <COMMAND>
                              (e.g., 'minitar help create')
  EOH
end

#nameObject



308
309
310
# File 'lib/gems/archive-tar-minitar-0.5.2/lib/archive/tar/minitar/command.rb', line 308

def name
  "help"
end