Class: KamalBackup::CLI
- Inherits:
-
Thor
- Object
- Thor
- KamalBackup::CLI
show all
- Includes:
- Helpers
- Defined in:
- lib/kamal_backup/cli.rb
Defined Under Namespace
Modules: Helpers
Classes: CommandBase, DrillCLI, RestoreCLI
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Helpers
#accessory_name, #bridge, #command_env, #confirm!, #deploy_snippet, #deployment_mode?, #direct_app, #exec_remote, #init_config_root, #local_app, #local_command_config, #local_config_path, #local_config_template, #local_preferences, #prompt_required, #redactor, #shared_config_path, #shared_config_template, #write_init_file
Class Attribute Details
.command_env ⇒ Object
Returns the value of attribute command_env.
246
247
248
|
# File 'lib/kamal_backup/cli.rb', line 246
def command_env
@command_env
end
|
Class Method Details
.basename ⇒ Object
284
285
286
|
# File 'lib/kamal_backup/cli.rb', line 284
def self.basename
"kamal-backup"
end
|
.normalize_global_options(argv) ⇒ Object
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
|
# File 'lib/kamal_backup/cli.rb', line 248
def normalize_global_options(argv)
tokens = Array(argv).dup
leading = []
while tokens.any?
token = tokens.first
case token
when "-d", "--destination", "-c", "--config-file"
leading << tokens.shift
leading << tokens.shift if tokens.any?
when /\A--destination=.+\z/, /\A--config-file=.+\z/
leading << tokens.shift
else
break
end
end
if leading.empty? || tokens.empty?
Array(argv)
else
[tokens.shift, *leading, *tokens]
end
end
|
.start(argv = ARGV, env: ENV) ⇒ Object
288
289
290
291
292
293
294
295
296
297
298
299
|
# File 'lib/kamal_backup/cli.rb', line 288
def self.start(argv = ARGV, env: ENV)
self.command_env = env
super(normalize_global_options(argv))
rescue Error => e
warn("kamal-backup: #{Redactor.new(env: env).redact_string(e.message)}")
exit(1)
rescue Interrupt
warn("kamal-backup: interrupted")
exit(130)
ensure
self.command_env = nil
end
|
Instance Method Details
#backup ⇒ Object
304
305
306
307
308
309
310
|
# File 'lib/kamal_backup/cli.rb', line 304
def backup
if deployment_mode?
exec_remote(["kamal-backup", "backup"])
else
direct_app.backup
end
end
|
#check ⇒ Object
322
323
324
325
326
327
328
|
# File 'lib/kamal_backup/cli.rb', line 322
def check
if deployment_mode?
exec_remote(["kamal-backup", "check"])
else
puts(direct_app.check)
end
end
|
#evidence ⇒ Object
331
332
333
334
335
336
337
|
# File 'lib/kamal_backup/cli.rb', line 331
def evidence
if deployment_mode?
exec_remote(["kamal-backup", "evidence"])
else
puts(direct_app.evidence)
end
end
|
#init ⇒ Object
340
341
342
343
344
345
346
347
348
|
# File 'lib/kamal_backup/cli.rb', line 340
def init
write_init_file(shared_config_path, shared_config_template)
write_init_file(local_config_path, local_config_template)
puts
puts "Add this accessory block to your Kamal deploy config:"
puts
puts deploy_snippet
end
|
#list ⇒ Object
313
314
315
316
317
318
319
|
# File 'lib/kamal_backup/cli.rb', line 313
def list
if deployment_mode?
exec_remote(["kamal-backup", "list"])
else
puts(direct_app.snapshots)
end
end
|
#schedule ⇒ Object
351
352
353
354
355
356
357
|
# File 'lib/kamal_backup/cli.rb', line 351
def schedule
if deployment_mode?
exec_remote(["kamal-backup", "schedule"])
else
direct_app.schedule
end
end
|
#version ⇒ Object
360
361
362
363
364
365
366
|
# File 'lib/kamal_backup/cli.rb', line 360
def version
if deployment_mode?
exec_remote(["kamal-backup", "version"])
else
puts(VERSION)
end
end
|