Class: Norikra::Client::Query
- Inherits:
-
Thor
- Object
- Thor
- Norikra::Client::Query
show all
- Includes:
- CLIUtil
- Defined in:
- lib/norikra/client/cli.rb
Instance Method Summary
collapse
Methods included from CLIUtil
#client, #formatter, #parser, #wrap
Instance Method Details
#add(query_name, expression) ⇒ Object
97
98
99
100
101
|
# File 'lib/norikra/client/cli.rb', line 97
def add(query_name, expression)
wrap do
client(parent_options).register(query_name, options[:group], expression)
end
end
|
#list ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/norikra/client/cli.rb', line 79
def list
wrap do
puts ["NAME", "GROUP", "TARGETS", "QUERY"].join("\t") unless options[:simple]
queries = client(parent_options).queries
queries.sort{|a,b| (a['targets'].first <=> b['targets'].first).nonzero? || a['name'] <=> b['name']}.each do |q|
puts [
q['name'],
(q['group'] || 'default'),
q['targets'].join(','),
q['expression'].split("\n").map(&:strip).join(" ")
].join("\t")
end
puts "#{queries.size} queries found." unless options[:simple]
end
end
|
#remove(query_name) ⇒ Object
104
105
106
107
108
|
# File 'lib/norikra/client/cli.rb', line 104
def remove(query_name)
wrap do
client(parent_options).deregister(query_name)
end
end
|