#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler/setup' require 'ace_of_base' require 'optionparser' options = {} OptionParser.new do |opts| opts.on('-h', '--help', 'Show this help message') do puts opts exit(0) end opts.on('-s FIELDS', '--select FIELDS', 'Specify fields to select out of the results. Defaults to all fields.') do |value| options[:select] = value.split(/\s*,\s*/).map { |f| f.split(/\s*:\s*/) } end opts.on('-f FUNCTION', '--filter FUNCTION', 'Restrict the results to those that match the specified filters.') do |value| options[:filter] = value end opts.on('-g FIELDS', '--group FIELDS', 'Group the results by specified fields, required if the select contains aggregations.') do |value| options[:group] = value.split(/\s*,\s*/) end end.parse! puts options.inspect