Module: BackupGithub::Cli

Defined in:
lib/backup-github/cli.rb

Class Method Summary collapse

Class Method Details

.parse_optionsObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/backup-github/cli.rb', line 7

def self.parse_options
  opts = Trollop::options do
    banner "hola mundo"
    opt :localrepo, "Path to the local repository where backups are saved", 
      :short => "-r",
      :type => String,
      :required => true
    opt :organization, "Organization name if you want to backup repositories from one", 
      :short => "-o",
      :type => String,
      :required => false
    opt :github_user, "Github User", 
      :short => "-u",
      :type => String,
      :required => true
    opt :github_password, "Github Password", 
      :short => "-p",
      :type => String,
      :required => true
  end
  Trollop::die :localrepo, "must exist" unless File.directory? opts[:localrepo]
  opts
end

.runObject



31
32
33
34
35
36
37
38
39
# File 'lib/backup-github/cli.rb', line 31

def self.run
  opts = parse_options
   = opts[:organization] || opts[:github_user]
  github = GithubAPIAdapter.new(
            Octokit::Client.new(
              :login => opts[:github_user], 
              :password => opts[:github_password]))
  GithubBackup.new(github).run(, opts[:localrepo])
end