#!/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 unless RocketApi::CHECK_APPS.map { |p| Dir.glob(p) }.flatten.empty? puts RocketApi::APP_DETECTED return end case when RocketApi::AVAILABLE_COMMANDS.keys.include?(base_command) if RocketApi::AVAILABLE_COMMANDS[base_command].keys.include?(sub_command) RocketApi::AVAILABLE_COMMANDS[base_command][sub_command].each do |key, collection| RocketApi::RocketCommands.send(key, collection: collection, 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