Class: RestoreBundledWith::CLI

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/restore_bundled_with/cli.rb', line 5

def self.exit_on_failure?
  true
end

Instance Method Details

#deleteObject



56
57
58
59
60
61
62
63
64
# File 'lib/restore_bundled_with/cli.rb', line 56

def delete
  setup_logger(options)

  data = read_data(options)
  puts Lock.new(data).delete_bundled_with
rescue StandardError => e
  suggest_messages(options)
  raise e
end

#fetchObject



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/restore_bundled_with/cli.rb', line 74

def fetch
  setup_logger(options)
  lock_file = Repository
              .new(options[:git_path], options[:git_options])
              .fetch_file(
                options[:lockfile],
                options[:ref],
                options[:new_line]
              )
  puts Lock
    .new(lock_file)
    .pick
rescue StandardError => e
  suggest_messages(options)
  raise e
end

#restoreObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/restore_bundled_with/cli.rb', line 30

def restore
  setup_logger(options)

  params = options.dup
  params[:file] = options[:lockfile] if !options[:data] && !options[:file]
  data = read_data(params)
  lock_file = Lock.restore(
    data,
    options[:lockfile],
    options[:ref],
    options[:git_path],
    options[:git_options],
    options[:new_line]
  )
  File.write(options[:lockfile], lock_file.body)
rescue StandardError => e
  suggest_messages(options)
  raise e
end

#versionObject



12
13
14
15
16
17
18
# File 'lib/restore_bundled_with/cli.rb', line 12

def version
  if options[:digit]
    print ::RestoreBundledWith::VERSION
  else
    puts "RestoreBundledWith version #{::RestoreBundledWith::VERSION}"
  end
end