Sha256: 35af28fa7a874a1cbedb3adbb6835e62e5b44138ef46ce13b9939197f7eaac01

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

require 'commander'

require_relative 'cli/setup'

module BackupRepos
  class Commander
    include ::Commander::Methods

    def run
      program :name, 'Backup Repos'
      program :version, BackupRepos::VERSION
      program :description, 'Backup your repositories to specified directory.'

      command :backup do |c|
        c.syntax = 'backup-repos backup'
        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::CLI::Setup.new(options).call
        end
      end

      run!
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
backup_repos-0.3.0 lib/backup_repos/commander.rb
backup_repos-0.2.1 lib/backup_repos/commander.rb
backup_repos-0.2.0 lib/backup_repos/commander.rb