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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/evm/cli.rb', line 5
def self.parse(argv)
options = {}
optparse = OptionParser.new do |opts|
opts.banner += ' command'
opts.separator ''
opts.separator 'Emacs Version Manager.'
opts.separator ''
opts.separator 'Commands:'
opts.separator ' install Install package name'
opts.separator ' uninstall Uninstall package name'
opts.separator ' bin [name] Show path to Emacs binary for package name'
opts.separator ' list List all available packages'
opts.separator ' use <name> Select name as current package'
opts.separator ' disuse Stop using the current package (remove binary from path but leave installed)'
opts.separator ' config <var> <value> Set the value of a configuration variable (like path)'
opts.separator ' help Display this help message'
opts.separator ''
opts.separator 'Options:'
opts.on('--force', 'Force install even when already installed') do
options[:force] = true
end
opts.on('--skip', 'Ignore if already installed') do
options[:skip] = true
end
opts.on('--use', 'Select as current package after installing') do
options[:use] = true
end
opts.on_tail('--help', '-h', 'Display this help message') do
puts opts
exit
end
end
optparse.parse!(argv)
command = argv.shift
if command == 'help' || !command
puts optparse
exit
end
begin
const = Evm::Command.const_get(command.capitalize)
rescue NameError
raise Evm::Exception, "No such command: #{command}"
end
const.new(argv, options)
end
|