-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathcli.rb
41 lines (38 loc) · 1.09 KB
/
cli.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require 'thor'
require 'fileutils'
require 'logger'
require 'colorize'
require './src/methods'
require './src/utils'
# Terrapin::CommandLine.logger = Logger.new(STDOUT)
module VBiosFinder
@@wd
class CLI < Thor
desc 'extract <bios update file>'.colorize(:blue), 'attempts to extract an embedded vbios from a bios update'
def extract(file = nil)
wd = "#{Dir.pwd}/tmp-vbiosfinder"
if file.nil?
puts 'no file specified'.colorize(:red)
return
end
if File.directory? wd
puts "dirty work directory! remove #{wd}".colorize(:red)
exit 1
end
FileUtils.mkdir_p wd
Kernel.at_exit do
puts 'Cleaning up garbage'.colorize(:blue)
FileUtils.remove_entry_secure wd
end
@@wd = wd
Dir.chdir wd
puts "output will be stored in '#{wd}'".colorize(':blue')
Utils.installed?('ruby') # "bugfix"
Utils.get_new_files # "bugfix" #2
FileUtils.cp(file, wd)
puts 'copying BIOS file to the work directory'.colorize(':blue')
puts
Main.run Utils.get_new_files.first
end
end
end