#!/usr/bin/env ruby require "rocket_api" base_command = ARGV[0]&.gsub(RocketApi::REGEXP_VALID, '')&.downcase sub_command = ARGV[1]&.gsub(RocketApi::REGEXP_VALID, '')&.downcase project_name = ARGV[2]&.gsub(RocketApi::REGEXP_VALID, '')&.downcase if [base_command, sub_command, project_name].map(&:nil?).any? puts RocketApi::WRONG_RESPONSE return end case when RocketApi::AVAILABLE_COMMANDS.keys.include?(base_command&.to_sym) if RocketApi::AVAILABLE_COMMANDS[base_command&.to_sym].keys.include?(sub_command&.to_sym) RocketApi::AVAILABLE_COMMANDS[base_command&.to_sym][sub_command&.to_sym].each do |command| RocketApi::RocketCommands.send(command, project_name: project_name) rescue RocketApi::Error => e puts "#{RocketApi::INIT_DIR_ERROR} #{e.message}" return end else puts RocketApi::WRONG_RESPONSE end else puts RocketApi::WRONG_RESPONSE end