control:fanctl: Option to do dump before query

Add a -d option to the 'fanctl query_dump' command that will generate
the dump and do the query in one step.  Previously the dump had to be
generated first with the 'fanctl dump' command.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ibe0b60ca75f2390fea03ea450bfd4da6a57f57b6
diff --git a/control/fanctl.cpp b/control/fanctl.cpp
index 280fbe5..d244a86 100644
--- a/control/fanctl.cpp
+++ b/control/fanctl.cpp
@@ -48,6 +48,7 @@
     std::string section;
     std::string name;
     std::vector<std::string> properties;
+    bool dump{false};
 };
 
 /**
@@ -735,6 +736,8 @@
                              "Optional dump file entry name (or substring)");
     cmdDumpQuery->add_option("-p, --properties", dq.properties,
                              "Optional list of dump file property names");
+    cmdDumpQuery->add_flag("-d, --dump", dq.dump,
+                           "Force a dump before the query");
 #endif
 }
 
@@ -795,6 +798,10 @@
 #ifdef CONTROL_USE_JSON
         else if (app.got_subcommand("query_dump"))
         {
+            if (dq.dump)
+            {
+                dumpFanControl();
+            }
             queryDumpFile(dq);
         }
 #endif