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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/imba/cli.rb', line 8
def self.execute(stdout, argv)
option_parser = OptionParser.new do |opts|
opts.banner = "Usage: #{EXECUTABLE} command [arguments...] [options...]"
opts.on('--init', 'Initialize imba data store in current directory') do
if File.directory?('.imba')
stdout.puts 'here is already an .imba directory'
else
"#{PATH}/.imba".tap { |dir| FileUtils.mkdir_p(dir) }
Imba::DataStore.init
Imba::DataStore.migrate
end
exit
end
opts.on('--destroy', 'Remove all .imba files and data store from current directory') do
if File.directory?('.imba')
FileUtils.rm_rf(Imba::DIRECTORY)
else
stdout.puts 'nothing to destroy here'
end
exit
end
opts.on('-s', '--synch', 'Scan movies and update database') do
Imba::MovieList.new.synch
exit
end
opts.on('-l', '--list', 'List all your movies') do
stdout.puts Imba::Movie.list
exit
end
opts.on('-v', '--version', 'Show current version') do
stdout.puts "IMBA #{Imba::VERSION}"
exit
end
opts.on('-h', '--help', 'Display this screen') do
stdout.puts opts
exit
end
opts.on('-e', 'execute raw ruby in the "Imba::*" scope (just for dev purpose, will be removed soon!)') do
stdout.puts eval("Imba::#{argv[0]}")
exit
end
end
option_parser.parse!
stdout.puts option_parser.help if argv.empty?
end
|