Updated mcollective.init according to OSCI-658
[packages/precise/mcollective.git] / plugins / mcollective / application / doc.rb
diff --git a/plugins/mcollective/application/doc.rb b/plugins/mcollective/application/doc.rb
new file mode 100644 (file)
index 0000000..07de85b
--- /dev/null
@@ -0,0 +1,25 @@
+module MCollective
+  class Application::Doc<Application
+    description "Error message help"
+    usage "rpc help [ERROR]"
+
+    def post_option_parser(configuration)
+      configuration[:query] = ARGV.shift if ARGV.size > 0
+    end
+
+    def msg_template
+      File.read(File.join(Config.instance.helptemplatedir, "msg-help.erb"))
+    end
+
+    def main
+      if configuration[:query] =~ /^PLMC\d+$/i
+        msg_code = configuration[:query].upcase
+        msg_example = Util.t("%s.example" % msg_code, :raise => true) rescue Util.t("%s.pattern" % msg_code)
+        msg_detail = Util.t("%s.expanded" % msg_code)
+
+        helptext = ERB.new(msg_template, 0, '%')
+        puts helptext.result(binding)
+      end
+    end
+  end
+end