lib/dexter/client.rb in pgdexter-0.4.3 vs lib/dexter/client.rb in pgdexter-0.5.0
- old
+ new
@@ -5,11 +5,11 @@
attr_reader :arguments, :options
def self.start
Dexter::Client.new(ARGV).perform
- rescue Dexter::Abort, PG::UndefinedFile => e
+ rescue Dexter::Abort, PG::UndefinedFile, PG::FeatureNotSupported => e
abort colorize(e.message.strip, :red)
end
def initialize(args)
@arguments, @options = parse_args(args)
@@ -25,31 +25,35 @@
elsif options[:pg_stat_statements]
# TODO support streaming option
Indexer.new(options).process_stat_statements
elsif options[:pg_stat_activity]
Processor.new(:pg_stat_activity, options).perform
- elsif options[:log_table]
- Processor.new(:log_table, options).perform
elsif arguments.any?
ARGV.replace(arguments)
+ if !options[:input_format]
+ ext = ARGV.map { |v| File.extname(v) }.uniq
+ options[:input_format] = ext.first[1..-1] if ext.size == 1
+ end
Processor.new(ARGF, options).perform
- else
+ elsif options[:stdin]
Processor.new(STDIN, options).perform
+ else
+ raise Dexter::Abort, "Specify a source of queries: --pg-stat-statements, --pg-stat-activity, --stdin, or a path"
end
end
def parse_args(args)
opts = Slop.parse(args) do |o|
o.banner = %(Usage:
dexter [options])
o.separator ""
o.separator "Input options:"
- o.string "--input-format", "input format", default: "stderr"
- o.string "--log-table", "log table (experimental)"
- o.boolean "--pg-stat-activity", "use pg_stat_activity", default: false, help: false
+ o.string "--input-format", "input format"
+ o.boolean "--pg-stat-activity", "use pg_stat_activity", default: false
o.boolean "--pg-stat-statements", "use pg_stat_statements", default: false, help: false
+ o.boolean "--stdin", "use stdin", default: false
o.string "-s", "--statement", "process a single statement"
o.separator ""
o.separator "Connection options:"
o.string "-d", "--dbname", "database name"
@@ -60,15 +64,15 @@
o.separator "Processing options:"
o.integer "--interval", "time to wait between processing queries, in seconds", default: 60
o.float "--min-calls", "only process queries that have been called a certain number of times", default: 0
o.float "--min-time", "only process queries that have consumed a certain amount of DB time, in minutes", default: 0
- o.boolean "--once", "run once", default: false, help: false
o.separator ""
o.separator "Indexing options:"
o.boolean "--analyze", "analyze tables that haven't been analyzed in the past hour", default: false
o.boolean "--create", "create indexes", default: false
+ o.boolean "--enable-hypopg", "enable the HypoPG extension", default: false
o.array "--exclude", "prevent specific tables from being indexed"
o.string "--include", "only include specific tables"
o.integer "--min-cost-savings-pct", default: 50, help: false
o.string "--tablespace", "tablespace to create indexes"
o.separator ""