Sha256: 4fb6fd8128dfdc452d7fffe05076fc31d6fe93f880256dc794c47804afc42886

Contents?: true

Size: 1.9 KB

Versions: 1

Compression:

Stored size: 1.9 KB

Contents

#!/usr/bin/env ruby

# Lets require our gems and start this
require "json"
require "fileutils"
require "git"
require "gitlab"
require "setup"
require "github"
require "version"
require "slop"
require "httparty"
require "rainbow"

opts = Slop.parse do
  on :h, :help, 'help'
  on :c, :clone, 'clone'
  on :w, :web, 'web'
  on :l, :list, 'list'
  on :v, :version, 'version'
  on :g, :group=, 'group'
  on :o, :github, 'github'
  on :n, :config, 'print config'
  on :r, :reconfigure, 'reconfigure gitlab server and token settings'
end

# If no arugments are passed, give help information
if ARGV[0].nil?
  Gitlab.printhelp
end

if opts[:o] && !Setup.github_precheck
  puts Rainbow("Whoops looks like you have not set your Github token yet. Would you like to do so now?").yellow
  answer = STDIN.gets.chomp.downcase
  if answer == "y" or answer == "yes"
    Setup.github_configure
  end
  exit
end


opts.to_hash

if opts[:c] && opts[:w]
  puts Rainbow("\n\t############################################").red
  puts Rainbow("\t    You can't web clone and ssh clone").red
  puts Rainbow("\t    gitlab-clone -h for more information").red
  puts Rainbow("\t############################################\n").red
else

if opts[:o] && !opts[:g]
  puts Rainbow("Github option requiers you to enter a organizational name.\n\n").red
end

if opts[:g]
  clone_group = opts[:g]
elsif opts[:l] || opts[:o] || opts[:w] || opts[:c]
  puts Rainbow("\nNo organizational or group name was given. Using default of \"Cookbooks\"\n\n").purple.italic
  clone_group = "Cookbooks"
end

if opts[:o]
  class_to_use = Github
else
  class_to_use = Gitlab
end

if opts[:h]
  Gitlab.printhelp
  elsif opts[:r]
    Setup.configure
  elsif opts[:c]
    class_to_use.clone(0, clone_group)
  elsif opts[:w]
    class_to_use.clone(1, clone_group)
  elsif opts[:v]
    Version::version
  elsif opts[:n]
    Gitlab.config
  elsif opts[:l]
    class_to_use.list_repos(clone_group)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gitlab_clone-0.12.1 bin/gitlab-clone