Explorar el Código

Re-enabled the --version command line option. (#19)

During the move from docopt to CLI11, the
--version command line option was lost because it was an implicit
option in docopt. In CLI11, the --version option must be explicitely
declared.

Signed-off-by: garrieta <[email protected]>
galibzon hace 3 años
padre
commit
7b81e5bd26
Se han modificado 1 ficheros con 10 adiciones y 2 borrados
  1. 10 2
      src/AzslcMain.cpp

+ 10 - 2
src/AzslcMain.cpp

@@ -299,9 +299,11 @@ int main(int argc, const char* argv[])
 
     CLI::App cli{ "Amazon Shader Language Compiler" };
 
+    bool printVersion = false;
+    cli.add_flag("--version", printVersion, "Prints version information");
+
     std::string inputFile;
-    cli.add_option("(- | FILE)", inputFile, "Input file (pass - to read from stdin).")
-        ->required(true);
+    cli.add_option("(- | FILE)", inputFile, "Input file (pass - to read from stdin).");
 
     std::string output;
     cli.add_option("-o", output, "Output file (writes to stdout if omitted).");
@@ -432,6 +434,12 @@ int main(int argc, const char* argv[])
         // Major.Minor.Revision
         auto versionString = string{"AZSL Compiler " AZSLC_MAJOR "." AZSLC_MINOR "." AZSLC_REVISION " "} + GetCurrentOsName().data();
 
+        if (printVersion)
+        {
+            std::cout << versionString << std::endl;
+            return 0;
+        }
+
         if (listPredefined)
         {
             verboseCout.m_on = false;