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
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
|
# File 'lib/bonethug/cli.rb', line 4
def self.handle
task = ARGV[0] || 'help'
case task
when 'help'
display_help
when 'install'
type = ARGV[1]
location = ARGV[2] || '.'
unless type
puts 'Usage: bonethug install [type] [location]'
return
end
Installer.install type, location
when 'init', 'update'
location = ARGV[1] || '.'
unless location
puts 'Usage: bonethug #{task} [location]'
return
end
Installer.bonethugise(location, task.to_sym)
when 'run',
'rake',
'drush',
'sake'
environment = ARGV.last
if task == 'run'
cmd_task = ARGV[1]
args = ARGV[2..(ARGV.length-2)]
else
case task
when 'rake'
cmd_task = 'rake'
when 'drush'
cmd_task = 'vendor/drush/drush'
when 'sake'
cmd_task = 'public/framework/sake'
end
args = ARGV[1..(ARGV.length-2)]
end
run = "\"run[#{cmd_task} #{args.join(' ')}]\""
exec "export to=#{environment} && bundle exec mina -f .bonethug/deploy.rb #{run} --verbose"
when 'deploy',
'setup',
'remote-backup',
'local-backup',
'sync-backup-to',
'sync-backup-from',
'sync-local-to',
'sync-local-from',
'init-db',
'force-unlock',
'cleanup'
environment = ARGV[1]
unless environment
puts 'Usage: bonethug #{task} [environment]'
return
end
case task
when 'deploy'
exec "export to=#{environment} && bundle exec mina -f .bonethug/deploy.rb deploy --verbose"
when 'setup'
exec "export to=#{environment} && bundle exec mina -f .bonethug/deploy.rb setup --verbose"
when 'init-db'
exec "export to=#{environment} && bundle exec mina -f .bonethug/deploy.rb init_db --verbose"
when 'force-unlock'
exec "export to=#{environment} && bundle exec mina -f .bonethug/deploy.rb deploy:force_unlock --verbose"
when 'cleanup'
exec "export to=#{environment} && bundle exec mina -f .bonethug/deploy.rb deploy:cleanup --verbose"
when 'remote-backup'
exec "export to=#{environment} && bundle exec mina -f .bonethug/deploy.rb backup --verbose"
when 'local-backup'
exec "export to=#{environment} && bundle exec astrails-safe .bonethug/backup.rb"
when 'sync-backup-to'
exec "export to=#{environment} && bundle exec mina -f .bonethug/deploy.rb sync_to --verbose"
when 'sync-backup-from'
exec "export to=#{environment} && bundle exec mina -f .bonethug/deploy.rb sync_from --verbose"
when 'sync-local-to'
exec "ruby .bonethug/syncer.rb sync_local_to #{environment}"
when 'sync-local-from'
exec "ruby .bonethug/syncer.rb sync_local_from #{environment}"
end
when 'watch'
type = ARGV[1] || 'coffee_sass'
location = ARGV[2] || '.'
watch_only = ARGV[3] || nil
Watcher.watch type, location, watch_only
when 'clean'
location = ARGV[1] || '.'
Installer.clean location
else
puts 'Task not found'
end
end
|