-
Notifications
You must be signed in to change notification settings - Fork 3
/
cli
executable file
·87 lines (67 loc) · 2.43 KB
/
cli
1
2
3
4
5
6
7
8
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
#!/usr/bin/env ruby
# use this script with this command : $ ./cli
require 'thor'
class CLI < Thor
include Thor::Actions
# Monkey patch for first screen customization
# inspiration : https://stackoverflow.com/a/45730659/3219759
class << self
def help(shell, subcommand = false)
list = printable_commands(true, subcommand)
Thor::Util.thor_classes_in(self).each do |klass|
list += klass.printable_commands(false)
end
# Remove this line to disable alphabetical sorting
# list.sort! { |a, b| a[0] <=> b[0] }
# Add this line to remove the help-command itself from the output
list.reject! { |l| l[0].split[1] == 'help' }
shell.say 'Commands:'
shell.say
staging_commands = list.select { |a| a[0].include? 'staging' }
production_commands = list.select { |a| a[0].include? 'prod' }
shell.say 'Staging'
shell.print_table(staging_commands, indent: 2, truncate: true)
shell.say
shell.say 'Production'
shell.print_table(production_commands, indent: 2, truncate: true)
shell.say
end
end
desc 'console_staging', 'launch MSJ staging rails console'
def console_staging
run('scalingo -a mon-suivi-justice-staging run rails console')
end
desc 'bash_staging', 'launch bash on MSJ staging'
def bash_staging
run('scalingo -a mon-suivi-justice-staging run bash')
end
desc 'logs_staging', 'streams MSJ staging logs'
def logs_staging
run('scalingo -a mon-suivi-justice-staging logs -f')
end
desc 'migrations_staging', 'launch migrations on MSJ staging'
def migrations_staging
run('scalingo -a mon-suivi-justice-staging run rails db:migrate')
end
desc 'deploy_prod', 'launch deploy-prod script'
def deploy_prod
run('scripts/deploy-prod')
end
desc 'console_prod', 'launch MSJ production rails console'
def console_prod
run('scalingo -a mon-suivi-justice-prod --region osc-secnum-fr1 run rails console')
end
desc 'bash_prod', 'launch bash on MSJ prod'
def bash_prod
run('scalingo -a mon-suivi-justice-prod --region osc-secnum-fr1 run bash')
end
desc 'logs_prod', 'streams MSJ production logs'
def logs_prod
run('scalingo -a mon-suivi-justice-prod --region osc-secnum-fr1 logs -f')
end
desc 'migrations_prod', 'launch migrations on MSJ production'
def migrations_prod
run('scalingo -a mon-suivi-justice-prod --region osc-secnum-fr1 run rails db:migrate')
end
end
CLI.start(ARGV)