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
|
# File 'lib/mkbrut/cli.rb', line 12
def run
command = if @args.first == "add-segment"
@args.shift
:add_segment
elsif @args.first == "new-app" || @args.first == "new"
@args.shift
:new_app
else
:new_app
end
if command == :new_app
app_options = parse_options(@args, MKBrut::Versions.new)
new_app = MKBrut::App.new(
current_dir: Pathname.pwd.expand_path,
app_options:,
out: PrefixedIO.new(@out, "mkbrut"),
err: @err
)
new_app.create!
elsif command == :add_segment
add_segment_options = parse_add_segment_options(@args, MKBrut::Versions.new)
add_segment = MKBrut::AddSegment.new(
current_dir: add_segment_options.project_root,
add_segment_options:,
out: PrefixedIO.new(@out, "mkbrut"),
err: @err
)
add_segment.add!
@out.puts ""
@out.puts "Sidekiq has now been set up for your app. The configuration used is"
@out.puts "a basic one, suitable for getting started, however you know own this"
@out.puts "configuration. Most of it is in these files:"
@out.puts ""
@out.puts " app/config/sidekiq.yml"
@out.puts " app/src/back_end/segments/sidekiq_segment.rb"
@out.puts ""
@out.puts "You are encouraged to verify everything is set up as follows:"
@out.puts ""
@out.puts "1. Quit dx/start, and start it back up - this will downloaded and set up ValKey/Redis"
@out.puts "2. Re-run bin/setup. This will install needed gems and create binstubs"
@out.puts "3. Run the example integration test:"
@out.puts ""
@out.puts " bin/test e2e specs/integration/sidekiq_works.spec.rb"
@out.puts ""
@out.puts " This will use the actual Sidekiq server, so if it passes, you should"
@out.puts " all set and can start creating jobs"
@out.puts ""
else
raise "Unknown command #{command}"
end
0
rescue => e
@err.puts "Error: #{e.message}"
if ENV["BRUT_CLI_RAISE_ON_ERROR"] == "true"
raise
end
1
end
|