#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' begin require 'dotenv' Dotenv.load rescue LoadError end require 'zoho_hub/cli/callback_server' require 'zoho_hub/cli/read_modules' command = ARGV[0] def print_commands commands = [ ['callback-server', 'run a http server to serve as oauth callback to get a refresh token'], ['read-modules', 'read the configuration from Zoho CRM and save it locally'] ] largest_name = commands.map(&:first).max_by(&:length) left_pad = largest_name.length + 5 commands.each do |command| $stdout.print " #{command.first}".ljust(left_pad) $stdout.puts command.last end end case command when 'callback-server' ZohoHub::Cli::CallbackServer.new.run(ARGV[1..-1]) when 'read-modules' ZohoHub::Cli::ReadModules.new.run(ARGV[1..-1]) else $stdout.puts 'Usage:' $stdout.puts " zoho_hub [command] [options]\n" $stdout.puts 'where is one of:' print_commands end