lib/makit/cli/clone.rb in makit-0.0.5 vs lib/makit/cli/clone.rb in makit-0.0.6

- old
+ new

@@ -1,59 +1,59 @@ -# frozen_string_literal: true - -require "clamp" -#require "git" - -module Makit - module Cli - # Define the 'clone' subcommand - class CloneCommand < Clamp::Command - parameter "GIT_REPOSITORY", "The git repository url", attribute_name: :git_repository, required: true - - def execute - clone_dir = Directories::get_clone_directory(git_repository) - puts "cloning repository: #{git_repository} to #{clone_dir}" - begin - Makit::clone(git_repository) - if !Dir.exist?(clone_dir) - summary = "failed to clone repository: #{git_repository} to #{clone_dir}\n" - summary += "Please check the URL and your network connection.\n" - summary += "stdout: #{clone.stdout}\n" - summary += "stderr: #{clone.stderr}\n" - $stderr.puts summary - exit 1 - end - rescue => e - # $stderr.puts "failed to clone repository: #{git_repository} to #{clone_dir}" - puts e.message - exit 1 - end - #puts "size of clone directory: #{clone_dir} is #{Humanize::get_humanized_size(Directory::get_size(clone_dir))}" - end - - #def self.clone(git_repository) - # make sure a local clone of the repository exists - # clone_dir = Directories::get_clone_directory(git_repository) - # raise "clone directory already exists: #{clone_dir}" if Dir.exist?(clone_dir) - # begin - # clone_command = Makit::RUNNER.execute("git clone #{git_repository} #{clone_dir}") - # if !Dir.exist?(clone_dir) - # summary = "failed to clone repository: #{git_repository} to #{clone_dir}\n" - # summary += "Please check the URL and your network connection.\n" - # summary += "stdout: #{clone_command.stdout}\n" - # summary += "stderr: #{clone_command.stderr}\n" - # raise Makit::Error, summary - # end - #raise "failed to clone repository: #{git_repository} to #{clone_dir}" unless clone_command.success? - #Git.clone(git_repository, clone_dir) - # rescue => e - # summary = "=" * 80 + "\n" - # summary += "failed to clone repository: #{git_repository} to #{clone_dir}\n\n" - # summary += "Please check the URL and your network connection.\n" - # summary += "#{e.message}\n\n" - # summary += "=" * 80 + "\n" - # raise Makit::Error, summary - # end - #end - end - end -end +# frozen_string_literal: true + +require "clamp" +#require "git" + +module Makit + module Cli + # Define the 'clone' subcommand + class CloneCommand < Clamp::Command + parameter "GIT_REPOSITORY", "The git repository url", attribute_name: :git_repository, required: true + + def execute + clone_dir = Directories::get_clone_directory(git_repository) + puts "cloning repository: #{git_repository} to #{clone_dir}" + begin + Makit::clone(git_repository) + if !Dir.exist?(clone_dir) + summary = "failed to clone repository: #{git_repository} to #{clone_dir}\n" + summary += "Please check the URL and your network connection.\n" + summary += "stdout: #{clone.stdout}\n" + summary += "stderr: #{clone.stderr}\n" + $stderr.puts summary + exit 1 + end + rescue => e + # $stderr.puts "failed to clone repository: #{git_repository} to #{clone_dir}" + puts e.message + exit 1 + end + #puts "size of clone directory: #{clone_dir} is #{Humanize::get_humanized_size(Directory::get_size(clone_dir))}" + end + + #def self.clone(git_repository) + # make sure a local clone of the repository exists + # clone_dir = Directories::get_clone_directory(git_repository) + # raise "clone directory already exists: #{clone_dir}" if Dir.exist?(clone_dir) + # begin + # clone_command = Makit::RUNNER.execute("git clone #{git_repository} #{clone_dir}") + # if !Dir.exist?(clone_dir) + # summary = "failed to clone repository: #{git_repository} to #{clone_dir}\n" + # summary += "Please check the URL and your network connection.\n" + # summary += "stdout: #{clone_command.stdout}\n" + # summary += "stderr: #{clone_command.stderr}\n" + # raise Makit::Error, summary + # end + #raise "failed to clone repository: #{git_repository} to #{clone_dir}" unless clone_command.success? + #Git.clone(git_repository, clone_dir) + # rescue => e + # summary = "=" * 80 + "\n" + # summary += "failed to clone repository: #{git_repository} to #{clone_dir}\n\n" + # summary += "Please check the URL and your network connection.\n" + # summary += "#{e.message}\n\n" + # summary += "=" * 80 + "\n" + # raise Makit::Error, summary + # end + #end + end + end +end