Sha256: d9195157b34f440d917f2b2b1de907ff1064b8946bc0605d08d4680a8b0d007c

Contents?: true

Size: 1.64 KB

Versions: 5

Compression:

Stored size: 1.64 KB

Contents

#!/usr/bin/env ruby
require_relative '../lib/github_cloner'

if ARGV.empty?
  OptParser.parse(%w[--help])
end

include GithubCloner

options = OptParser.parse(ARGV)

# Mandatory options
raise "base_dir is required" if options.base_dir.nil?
raise "user is required"     if options.user.nil?

# Make use of the user name
gh_id = options.user

if options.languages
  languages = options.languages
end

args = {
  base_dir:      options.base_dir,
  oauth_token:   options.oauth_token,
  user:          options.user,
  org:           options.org,
  all_repos:     options.all_repos,
  group_by_user: options.group_by_user,
  clone_repos:   options.clone_repos,
  repo_host:     options.repo_host
}

repos = GithubCloner::GithubUtils.list_all(args)

# List of language that have been used by the given user/organization
repo_languages = repos.map(&:language).uniq.compact
puts "------------------------------------------"
puts "List of languages by #{gh_id}"
puts repo_languages
puts "------------------------------------------"

repos_hash = GithubCloner::GithubUtils.repos_by_language(repos, repo_languages)

result = GithubCloner::GithubUtils.repos_as_list(repos_hash)

if result && !result.empty?
  puts "------------------------------------------"
  puts "List of all repositories by #{gh_id}"
  result.each_with_index do |r,i|
    puts "#{i+1}/#{result.size}: #{r}"
  end
  puts "------------------------------------------"

  # Need to get this from the list of language
  if languages && !languages.empty?
    result.keep_if do |i|
      lang = i.split(File::SEPARATOR)[1]
      languages.include?(lang)
    end
  end

  GithubCloner::GithubUtils.clone_all(result, args)
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
github-cloner-0.6.0 bin/github-cloner
github-cloner-0.5.3 bin/github-cloner
github-cloner-0.5.2 bin/github-cloner
github-cloner-0.5.1 bin/github-cloner
github-cloner-0.5.0 bin/github-cloner