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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/saruman/cli.rb', line 9
def extension
options = Hash.new
options[:command] = __method__
options[:namespace] = ask("Enter extension namespace:") { |q| q.default = "Saruman" }
options[:name] = ask("Enter extension name:") { |q| q.default = "Wizard" }
options[:author] = ask("Author of extension:") { |q| q.default = "Jason Ayre www.bravenewwebdesign.com" }
options[:version] = ask("Version number (Format - 0.0.1):") { |q| q.default = "0.0.1" }
options[:combined_namespace] = "#{options[:namespace]}_#{options[:name]}"
say("Would you like to create a controller?")
choose do ||
.choice(:yes) { options[:controller] = true }
.choice(:no) { options[:controller] = false }
end
if(options[:controller])
options[:controller_front_name] = ask("Enter Front Name of controller (will match www.yourmagentoinstall.com/frontname)") { |q| q.default = "extension_name" }
if(options[:controllers]).nil?
options[:controllers] = Array.new
end
begin
question = Saruman::ControllerBuilder.new(options)
options[:controllers] << question.output
end while agree("Create another controller?")
end
say("Would you like to create an observer?")
choose do ||
.choice(:yes) { options[:observer] = true }
.choice(:no) { options[:observer] = false }
end
if(options[:observer])
say("Choose the events you would like to observe")
begin
choose do ||
if(options[:observer_events]).nil?
options[:observer_events] = Array.new
end
if @observer_menu_builder.nil?
@observer_menu_builder = Saruman::ObserverMenuBuilder.new()
else
@observer_menu_builder.display_choices()
end
end
end while agree("Observe another event?")
options[:observer_events] = @observer_menu_builder.decisions
end
say("Would you like to create a model?")
choose do ||
.choice(:yes) { options[:model] = true }
.choice(:no) { options[:model] = false }
end
if(options[:model])
if(options[:models]).nil?
options[:models] = Array.new
end
begin
question = Saruman::ModelBuilder.new(options)
options[:models] << question.output
end while agree("Create another model?")
end
say("Would you like to create a helper?")
choose do ||
.choice(:yes) { options[:helper] = true }
.choice(:no) { options[:helper] = false }
end
Saruman::Generators::Extension.start([options])
if options[:model]
Saruman::Generators::Model.start([options])
end
if options[:controller]
Saruman::Generators::Controller.start([options])
end
end
|