Skip to content
This repository has been archived by the owner on Jun 29, 2019. It is now read-only.

Commit

Permalink
Make 'match' and 'print' commands for the augeas application, in a si…
Browse files Browse the repository at this point in the history
…milar way to augtool
  • Loading branch information
raphink committed Apr 14, 2012
1 parent afd7594 commit 6ac801e
Showing 1 changed file with 32 additions and 10 deletions.
42 changes: 32 additions & 10 deletions augeasquery/augeas.application.rb
@@ -1,8 +1,9 @@
class MCollective::Application::Augeas<MCollective::Application
description "Client to the AugeasQuery Plugin Execution system"
usage "Usage: augeas <query>"
usage "Usage: augeas [match|print] <path>"

def post_option_parser(configuration)
configuration[:command] = ARGV.shift if ARGV.size > 0
configuration[:query] = ARGV.shift if ARGV.size > 0
end

Expand All @@ -11,20 +12,41 @@ def validate_configuration(configuration)
end

def main
augeas = rpcclient("augeasquery")

augeas_results = augeas.query(:query => configuration[:query])
case configuration[:command]
when "match"
augeas = rpcclient("augeasquery")

puts
augeas_results = augeas.query(:query => configuration[:query])

augeas_results.each do |result|
printf("%-40s\n", result[:sender])
result[:data][:matched].each do |matched|
printf(" %-40s\n", matched)
puts

augeas_results.each do |result|
printf("%-40s\n", result[:sender])
result[:data][:matched].each do |matched|
printf(" %-40s\n", matched)
end
end
end

puts
puts

when "print"
augeas = rpcclient("augeasquery")

augeas_results = augeas.query(:query => configuration[:query]+"|"+configuration[:query]+"//*")

puts

augeas_results.each do |result|
printf("%-40s\n", result[:sender])
result[:data][:matched].each do |matched|
printf(" %-40s\n", matched)
end
end

puts

end

end
end

0 comments on commit 6ac801e

Please sign in to comment.