Skip to content
Snippets Groups Projects

Add 'gdk' command wrapper and gem

Merged Jacob Vosmaer (GitLab) requested to merge gdk-cli into master
1 unresolved thread
13 files
+ 117
29
Compare changes
  • Side-by-side
  • Inline
Files
13
bin/gdk 0 → 100755
+ 43
0
#!/usr/bin/env ruby
require 'fileutils'
# Gitlab Development Kit CLI launcher
#
# Note to contributors: this script must not change (much) because it is
# installed outside the gitlab-development-kit repository with 'gem
# install'. Edit lib/gdk.rb to define new commands.
def main
case ARGV.first
when 'init'
if ARGV.count > 2
puts "Usage: gdk init [DIR]"
return false
end
cmd = %W(git clone https://gitlab.com/gitlab-org/gitlab-development-kit.git)
cmd << ARGV[1] if ARGV.count == 2
system(*cmd)
else
$gdk_root = find_root(Dir.pwd)
if $gdk_root.nil?
puts "Could not find GDK_ROOT in the current directory or any of its parents."
return false
end
puts "(in #{$gdk_root})"
load(File.join($gdk_root, 'lib/gdk.rb'))
GDK::main
end
end
def find_root(current)
if File.exist?(File.join(current, 'GDK_ROOT'))
File.realpath(current)
elsif File.realpath(current) == '/'
nil
else
find_root(File.join(current, '..'))
end
end
exit(main)
Loading