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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
# File 'lib/blufin.rb', line 22
def self.execute
begin
unless ARGV[0] == 'setup' || ARGV[0] == 'x'
Blufin::Config::init(SCHEMA_FILE, TEMPLATE_FILE, App::CONFIG_FILE, App::GEM_NAME)
Blufin::Projects::init(Blufin::Config::get, App::CONFIG_FILE)
end
Convoy::App.create do |app|
app.version BLUFIN_VERSION
app.summary " \\x1B[48;5;20m\\x1B[38;5;255m Blufin \\x1B[0m\\x1B[0m \\x1B[38;5;32m\\xe2\\x80\\x94 Command-Line Interface \\xe2\\x80\\x94\\x1B[38;5;248m \u{1F433} \n\n\n\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\n\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\n\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2557 \u2588\u2588\u2551\n\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551\u2588\u2588\u2551\u255A\u2588\u2588\u2557\u2588\u2588\u2551\n\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2551\n\u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u255D\\x1B[0m\n"
app.description "The secret sauce that makes everything 'tick'..."
app.command :build, :aliases => [:b] do |build|
build.summary "Build #{Blufin::Terminal::format_highlight('project-specific')} java services #{Blufin::Terminal::format_invalid('@deprecated')}"
build.options do |opts|
opts.opt :skip_tests, 'Skip tests', :short => '-S', :long => '--skip', :type => :boolean
end
build.action do |opts, args|
AppCommand::Build.new(opts, args).execute
end
end
app.command :create, :aliases => [:c] do |create|
create.summary 'Create skeleton project from archetype(s)'
create.command :api, :aliases => [:a] do |create_api|
create_api.summary 'Create API skeleton'
create_api.action do |opts, args|
AppCommand::CreateApi.new(opts, args).execute
end
end
create.command :ui, :aliases => [:u] do |create_ui|
create_ui.summary 'Create UI skeleton'
create_ui.action do |opts, args|
AppCommand::CreateUI.new(opts, args).execute
end
end
create.action do
system("#{App::GEM_NAME} c -h")
end
end
app.command :export, :aliases => [:e] do |export|
export.summary 'Export internal data structures'
export.options do |opts|
opts.opt :maven_blufin, 'Maven BOM (Blufin)', :short => '-m', :long => '--maven-blufin', :type => :boolean
opts.opt :maven_app, 'Maven BOM (App)', :short => '-M', :long => '--maven-app', :type => :boolean
end
export.action do |opts, args|
AppCommand::Export.new(opts, args).execute
end
end
app.command :generate, :aliases => [:g] do |generate|
generate.summary "Generate #{Blufin::Terminal::format_highlight('code')} (and other things)"
generate.command :api, :aliases => [:a] do |generate_api|
generate_api.summary 'Generate boiler-plate API code (from YML files)'
generate_api.action do |opts, args|
AppCommand::GenerateApi.new(opts, args).execute
end
end
generate.command :lambda, :aliases => [:l] do |generate_lambda|
generate_lambda.summary 'Generate boiler-plate AWS Lambda code'
generate_lambda.action do |opts, args|
AppCommand::GenerateLambda.new(opts, args).execute
end
end
generate.command :ui, :aliases => [:u] do |generate_ui|
generate_ui.summary 'Generate UI stuff'
generate_ui.command :img_landing, :aliases => [:l] do |generate_ui_img_landing|
generate_ui_img_landing.summary 'Generate different landing page image sizes'
generate_ui_img_landing.options do |opts|
opts.opt :add_size, 'Add image size (in top-left corner)', :short => '-s', :long => '--add-size', :type => :boolean
opts.opt :quality, 'Quality of the image (default: 60)', :short => '-q', :long => '--quality', :type => :string, :default => '60'
opts.opt :skip_confirm, 'Skip confirmation', :short => '-y', :long => '--skip-confirm', :type => :boolean
end
generate_ui_img_landing.action do |opts, args|
AppCommand::GenerateUIImageLanding.new(opts, args).execute
end
end
generate_ui.command :img_favicon, :aliases => [:f] do |generate_ui_img_favicon|
generate_ui_img_favicon.summary 'Generate favicon.ico file'
generate_ui_img_favicon.action do |opts, args|
AppCommand::GenerateUIFavIcon.new(opts, args).execute
end
end
generate_ui.action do
system("#{App::GEM_NAME} g ui -h")
end
end
generate.action do
system("#{App::GEM_NAME} g -h")
end
end
app.command :lint, :aliases => [:l] do |lint|
lint.summary "Scans code for errors/anti-patterns #{Blufin::Terminal::format_invalid('@todo')}"
lint.action do |opts, args|
AppCommand::Lint.new(opts, args).execute
end
end
app.command :mysql, :aliases => [:M] do |mysql|
mysql.summary 'Manage development databases (and mock data)'
mysql.command :reset, :aliases => [:r] do |mysql_reset|
mysql_reset.summary 'Reset development databases to a standard configuration'
mysql_reset.options do |opts|
opts.opt :skip_confirm, 'Skip confirmation (a safety measure to prevent accidental reset)', :short => '-y', :long => '--skip-confirm', :type => :boolean
opts.opt :verbose, 'Verbose', :short => '-v', :long => '--verbose', :type => :boolean
end
mysql_reset.action do |opts, args|
AppCommand::MySQLReset.new(opts, args).execute
end
end
mysql.action do
system("#{App::GEM_NAME} M -h")
end
end
app.command :run, :aliases => [:r] do |run|
run.summary "Run a project/service #{Blufin::Terminal::format_invalid('@todo')}"
run.action do |opts, args|
AppCommand::Run.new(opts, args).execute
end
end
app.command :release, :aliases => [:R] do |release|
release.summary 'Create & deploy new releases'
release.command :blufin, :aliases => [:b] do |release_blufin|
release_blufin.summary 'Create and deploy the latest version of Blufin (along with all the gems, lambdas, etc.)'
release_blufin.action do |opts, args|
AppCommand::ReleaseBlufin.new(opts, args).execute
end
end
release.action do
system("#{App::GEM_NAME} R -h")
end
end
app.command :project, :aliases => [:p] do |project|
project.summary 'Information about Projects'
project.command :api_list, :aliases => [:al] do |project_api_list|
project_api_list.summary 'List all APIs'
project_api_list.action do |opts, args|
AppCommand::APIList.new(opts, args).execute
end
end
project.command :api_meta, :aliases => [:am] do |project_api_meta|
project_api_meta.summary 'Display various meta-data about an API'
project_api_meta.options do |opts|
opts.opt :show_auto_increment, "Show #{Blufin::Terminal::format_highlight('AUTO_INCREMENT')} columns", :short => '-a', :long => '--show-auto-increment', :type => :boolean
opts.opt :show_enums, "Show all available #{Blufin::Terminal::format_highlight('ENUMs')} (and their values)", :short => '-e', :long => '--show-enums', :type => :boolean
opts.opt :show_resources, "Show #{Blufin::Terminal::format_highlight('RESOURCE')} structure #{Blufin::Terminal::format_invalid('@deprecated')}", :short => '-r', :long => '--show-resources', :type => :boolean
opts.opt :as_json, 'Return meta-data as JSON (might not work for all paths)', :short => '-J', :long => '--as-json', :type => :boolean
end
project_api_meta.action do |opts, args|
AppCommand::APIMeta.new(opts, args).execute
end
end
project.action do
system("#{App::GEM_NAME} p -h")
end
end
app.command :config, :aliases => [:x] do |config|
config.summary 'Setup your configuration file'
config.action do
Blufin::Config::edit_config(App::CONFIG_FILE)
end
end
app.action do
system("#{App::GEM_NAME} -h")
end
end
rescue RuntimeError => e
Blufin::Terminal::print_exception(e);
end
end
|