class RepoMan::CLI

Public Instance Methods

fetch() click to toggle source
# File lib/repo_man/cli.rb, line 16
def fetch
  puts "Now cloning #{repos.size} repos from #{username}..."

  repos.each do |r|
    run("git clone #{r.ssh_url}") unless Dir.exist?(r.name)
  end
end
update() click to toggle source
# File lib/repo_man/cli.rb, line 25
def update
  puts 'Checking all current repos for updates...'

  repos.each do |r|
    run("cd #{r.name} && pwd && git pull --all") if Dir.exist?(r.name)
  end
end
version() click to toggle source
# File lib/repo_man/cli.rb, line 11
def version
  puts RepoMan::VERSION
end

Private Instance Methods

github() click to toggle source
# File lib/repo_man/cli.rb, line 51
def github
  @github ||= Github.new(
    auto_pagination: true,
    oauth_token: ENV['GITHUB_TOKEN'])
end
repos() click to toggle source
# File lib/repo_man/cli.rb, line 35
def repos
  @repos ||= github.repos.list user: username
rescue Github::Error::Unauthorized => e
  puts "\n  Missing or incorrect auth token. Please set GITHUB_TOKEN for this env.\n\n"
  puts e.inspect
  puts
rescue Github::Error::NotFound => e
  puts "\n  Incorrect user account. The account (#{username}) was not found.\n\n"
  puts e.inspect
  puts
end
run(cmd) click to toggle source
# File lib/repo_man/cli.rb, line 57
def run(cmd)
  puts cmd
  puts `#{cmd}` unless options[:pretend]
end
username() click to toggle source
# File lib/repo_man/cli.rb, line 47
def username
  @username ||= Dir.pwd.split(File::Separator).last
end