class Devpad::CLI::Commands::Image::Create
Public Class Methods
new(shell:)
click to toggle source
# File lib/devpad/cli/commands/image/create.rb, line 6 def initialize(shell:) @shell = shell end
Public Instance Methods
execute(params = {})
click to toggle source
# File lib/devpad/cli/commands/image/create.rb, line 10 def execute(params = {}) params.symbolize_keys! path = params.delete(:path) params[:name] = params[:name].parameterize if Dir.exists?("#{path}/.git") @shell.say("Current path already contains a git repository. Please change a directory first.") and return end if File.exists?("#{path}/devpad.yml") @shell.say('devpad.yml file already exists in the current directory') and return end image = Devpad::API::Image.create(image: params) if image.ssh_url @shell.say "Cloning #{image.ssh_url}" `cd #{path} && git clone #{image.ssh_url}` else @shell.say 'Could not create a git repository. No SSH url attached to the image.' end end