Class: Brut::CLI::Apps::New::App::Segment
Instance Attribute Summary
#parent_command
Instance Method Summary
collapse
#argv, #bootstrap?, #commands, #default_command, #default_command_class, #default_rack_env, #env, #env_vars, #execute, #name, #options, #puts, #stderr, #stdin, #stdout, #system!
Instance Method Details
#accepts ⇒ Object
177
178
179
|
# File 'lib/brut/cli/apps/new/app.rb', line 177
def accepts = [
[ Pathname, ->(value) { Pathname(value) } ],
]
|
#args_description ⇒ Object
175
|
# File 'lib/brut/cli/apps/new/app.rb', line 175
def args_description = "segment_name"
|
#description ⇒ Object
173
|
# File 'lib/brut/cli/apps/new/app.rb', line 173
def description = "Add a segement to your app to provide additional pre-configured functionality"
|
#opts ⇒ Object
181
182
183
184
185
186
187
188
189
190
191
|
# File 'lib/brut/cli/apps/new/app.rb', line 181
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
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
|
# File 'lib/brut/cli/apps/new/app.rb', line 193
def run
options.set_default(:dir,Pathname.pwd)
segment_name = argv[0]
if !segment_name
stderr.puts "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?
stdout.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:
)
end
if !segment
stderr.puts "'#{segment_name}' is not a segment. Allowed values: sidekiq, heroku"
return 1
end
stdout.puts "Adding #{segment_name} to this app"
segment.add!
segment.output_post_add_messaging(stdout:)
0
end
|