lib/uffizzi/cli/project/compose.rb in uffizzi-cli-0.5.2 vs lib/uffizzi/cli/project/compose.rb in uffizzi-cli-0.6.0

- old
+ new

@@ -10,72 +10,70 @@ class CLI::Project::Compose < Thor include ApiClient desc 'set [OPTIONS]', 'set' def set - run(options, 'set') + run('set') end desc 'unset', 'unset' def unset - run(options, 'unset') + run('unset') end desc 'describe', 'describe' def describe - run(options, 'describe') + run('describe') end private - def run(options, command) + def run(command) return Uffizzi.ui.say('You are not logged in.') unless Uffizzi::AuthHelper.signed_in? - return Uffizzi.ui.say('This command needs project to be set in config file') unless Uffizzi::AuthHelper.project_set? + return Uffizzi.ui.say('This command needs project to be set in config file') unless Uffizzi::AuthHelper.project_set?(options) + @project_slug = options[:project].nil? ? ConfigFile.read_option(:project) : options[:project] + @server = ConfigFile.read_option(:server) file_path = options[:file] case command when 'set' handle_set_command(file_path) when 'unset' handle_unset_command when 'describe' handle_describe_command - when 'validate' - handle_validate_command(file_path) end end def handle_set_command(file_path) return Uffizzi.ui.say('No file provided') if file_path.nil? - hostname = ConfigFile.read_option(:hostname) - project_slug = ConfigFile.read_option(:project) params = prepare_params(file_path) - response = set_compose_file(hostname, params, project_slug) + response = set_compose_file(@server, params, @project_slug) if ResponseHelper.created?(response) Uffizzi.ui.say('compose file created') else ResponseHelper.handle_failed_response(response) end end def handle_unset_command - hostname = ConfigFile.read_option(:hostname) + server = ConfigFile.read_option(:server) project_slug = ConfigFile.read_option(:project) - response = unset_compose_file(hostname, project_slug) + response = unset_compose_file(server, project_slug) if ResponseHelper.no_content?(response) Uffizzi.ui.say('compose file deleted') else ResponseHelper.handle_failed_response(response) end end def handle_describe_command - hostname = ConfigFile.read_option(:hostname) + server = ConfigFile.read_option(:server) project_slug = ConfigFile.read_option(:project) - response = describe_compose_file(hostname, project_slug) + response = describe_compose_file(server, project_slug) compose_file = response[:body][:compose_file] if ResponseHelper.ok?(response) if compose_file_valid?(compose_file) Uffizzi.ui.say(Base64.decode64(compose_file[:content]))