Class: Brut::CLI::Apps::New::App::Segment
Instance Attribute Summary
#parent_command
Instance Method Summary
collapse
#argv, #bootstrap?, #commands, #delegate_to_command, #detailed_description, #env, #env_vars, #execute, #name, #options, #print, #puts, #stdin, #system!, #theme
Instance Method Details
#accepts ⇒ Object
271
272
273
|
# File 'lib/brut/cli/apps/new/app.rb', line 271
def accepts = [
[ Pathname, ->(value) { Pathname(value) } ],
]
|
#args_description ⇒ Object
269
|
# File 'lib/brut/cli/apps/new/app.rb', line 269
def args_description = "segment_name"
|
#default_rack_env ⇒ Object
267
|
# File 'lib/brut/cli/apps/new/app.rb', line 267
def default_rack_env = nil
|
#description ⇒ Object
266
|
# File 'lib/brut/cli/apps/new/app.rb', line 266
def description = "Add a segement to your app to provide additional pre-configured functionality"
|
#opts ⇒ Object
275
276
277
278
279
280
281
282
283
284
285
|
# File 'lib/brut/cli/apps/new/app.rb', line 275
def opts = [
[
"--dir=DIR",
Pathname,
"Path to your app. Default is the current directory",
],
[
"--dry-run",
"Only show what would happen, don't actually do anything",
],
]
|
#run ⇒ Object
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
|
# File 'lib/brut/cli/apps/new/app.rb', line 287
def run
options.set_default(:dir,Pathname.pwd)
segment_name = argv[0]
if !segment_name
error "segment_name is required"
return 1
end
if options.demo?
segment_names << "demo"
end
project_root = options.dir.expand_path
versions = Brut::CLI::Apps::New::Versions.new
if options.dry_run?
puts "Dry Run"
Brut::CLI::Apps::New::Ops::BaseOp.dry_run = true
end
templates_dir = Pathname(
Gem::Specification.find_by_name("brut").gem_dir
) / "templates"
segment = if segment_name == "sidekiq"
Brut::CLI::Apps::New::Segments::Sidekiq.new(
project_root:,
templates_dir:
)
elsif segment_name == "heroku"
Brut::CLI::Apps::New::Segments::Heroku.new(
project_root:,
templates_dir:
)
elsif segment_name == "docker-deploy"
Brut::CLI::Apps::New::Segments::DockerDeploy.new(
project_root:,
templates_dir:
)
end
if !segment
error "'#{segment_name}' is not a segment. Allowed values: sidekiq, heroku"
return 1
end
puts "Adding #{segment_name} to this app"
segment.add!
segment.output_post_add_messaging(stdout: execution_context.stdout)
0
end
|