Commit 049c1ef

mokha <mokha@cisco.com>
2018-02-26 21:44:17
add export to file option.
1 parent 4ded943
Changed files (1)
lib
saml
kit
lib/saml/kit/cli/decode.rb
@@ -3,6 +3,7 @@ module Saml
     module Cli
       class Decode < Thor
         desc "redirect uri", "Decodes the uri using the HTTP Redirect binding"
+        method_option :export, default: nil, required: false
         def redirect(uri)
           print_report_for(redirect_binding.deserialize(uri))
         rescue StandardError => error
@@ -10,6 +11,7 @@ module Saml
         end
 
         desc "post saml", "Decodes the SAMLRequest/SAMLResponse using the HTTP Post binding"
+        method_option :export, default: nil, required: false
         def post(saml_request)
           print_report_for(post_binding.deserialize('SAMLRequest' => saml_request))
         rescue StandardError => error
@@ -26,7 +28,8 @@ module Saml
 
         private
 
-        def print_report_for(document)
+        def print_report_for(document, export = options[:export])
+          IO.write(export, document.to_xml) if export
           2.times { say "" }
           Report.new(document).print(self)
         end