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
|
# File 'lib/alet/irb/command/gen.rb', line 11
def execute(arg)
pastel = Pastel.new
argv = Shellwords.shellsplit(arg)
subcommands = {
'apex' => OptionParser.new,
'lwc' => OptionParser.new,
}
subcommands['apex'].on('-t', '--trigger')
subcommands['apex'].on('-o sobjectName', '--sobject')
subcommands['apex'].on('-e event1,event2,...', '--event')
subcommands['lwc'].on('-l label', '--label')
subcommands['lwc'].on('-d desc', '--description')
subcommands['lwc'].on('-e', '--exposed')
subcommands['lwc'].on('-t target1,target2,...', '--target')
subcommands['lwc'].on('-o object1,object2,...', '--object')
global_parser = OptionParser.new
global_parser.order!(argv)
if argv.empty?
puts pastel.red(t('gen.error.no_subcommand'))
return
end
unless subcommands.keys.include?(argv.first)
puts pastel.red(%|#{t('gen.error.invalid_subcommand')}: #{argv.first}|)
return
end
params = {}
subcommand = argv.shift
subcommands[subcommand].parse!(argv, into: params)
case subcommand
when 'apex'
gen_apex(argv, params)
when 'lwc'
gen_lwc(argv, params)
end
rescue => e
puts pastel.red(e.message)
end
|