Class: Excavate::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/excavate/cli.rb

Constant Summary collapse

STATUS_SUCCESS =
0
STATUS_UNKNOWN_ERROR =
1
STATUS_TARGET_EXISTS =
2
STATUS_TARGET_NOT_EMPTY =
3
STATUS_TARGET_NOT_FOUND =
4
ERROR_TO_STATUS =
{
  TargetExistsError => STATUS_TARGET_EXISTS,
  TargetNotEmptyError => STATUS_TARGET_NOT_EMPTY,
  TargetNotFoundError => STATUS_TARGET_NOT_FOUND,
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/excavate/cli.rb', line 19

def self.exit_on_failure?
  false
end

.start(given_args = ARGV, config = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/excavate/cli.rb', line 23

def self.start(given_args = ARGV, config = {})
  args = if all_commands.key?(given_args[0])
           given_args
         else
           given_args.dup.unshift("extract")
         end

  super(args, config)
end

Instance Method Details

#extract(archive, *files) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/excavate/cli.rb', line 39

def extract(archive, *files)
  target = Excavate::Archive.new(archive).extract(
    recursive_packages: options[:recursive],
    files: files,
    filter: options[:filter],
  )

  success("Successfully extracted to #{format_paths(target)}")
rescue Error => e
  handle_error(e)
end