lib/backup_repos/commander.rb in backup_repos-0.1.0 vs lib/backup_repos/commander.rb in backup_repos-0.2.0
- old
+ new
@@ -1,7 +1,9 @@
require 'commander'
+require_relative 'cli/setup'
+
module BackupRepos
class Commander
include ::Commander::Methods
def run
@@ -14,12 +16,28 @@
c.description = 'Backup your repositories.'
c.option '--backup_root DIR', String, 'Backup destination directory'
c.option '--debug', String, 'Show debug information'
+ c.action do |args, options|
+ BackupRepos.config_options = options
+
+ if args[0] && %w(github bitbucket gitlab).include?(args[0].downcase)
+ BackupRepos::Backup.new.send("process_#{args[0]}")
+ else
+ BackupRepos::Backup.new.process
+ end
+ end
+ end
+
+ command :setup do |c|
+ c.syntax = 'backup-repos setup'
+ c.description = 'Setup settings.'
+
+ c.option '--debug', String, 'Setup with debug flag.'
+
c.action do |_args, options|
- BackupRepos.config = options
- BackupRepos::Backup.new.process
+ BackupRepos::CLI::Setup.new(options).call
end
end
run!
end