This repository has been archived on 2024-06-24. You can view files and clone it, but cannot push or open issues or pull requests.
ace-of-base/exe/query

28 lines
841 B
Text
Raw Normal View History

#!/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