[latex3-commits] [git/LaTeX3-latex3-l3build] master: Special-case --help and --version (adbbd82)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Mar 6 16:40:45 CET 2018


Repository : https://github.com/latex3/l3build
On branch  : master
Link       : https://github.com/latex3/l3build/commit/adbbd8283d8ab2be64bdd749cdf8f7456ac47c8f

>---------------------------------------------------------------

commit adbbd8283d8ab2be64bdd749cdf8f7456ac47c8f
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Mar 6 15:40:45 2018 +0000

    Special-case --help and --version


>---------------------------------------------------------------

adbbd8283d8ab2be64bdd749cdf8f7456ac47c8f
 l3build-arguments.lua |    8 ++++----
 l3build-stdmain.lua   |    4 ----
 l3build.lua           |   10 +++++++++-
 3 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/l3build-arguments.lua b/l3build-arguments.lua
index 40c92d5..261d9db 100644
--- a/l3build-arguments.lua
+++ b/l3build-arguments.lua
@@ -141,12 +141,12 @@ local function argparse()
   result["target"] = "help"
   if a then
     -- No options are allowed in position 1, so filter those out
-    if not match(a, "^%-") then
-      result["target"] = a
+    if not match(a, "^%-") or a == "--version" then
+      result["target"] = "version"
     end
   end
-  -- Stop here if help is required
-  if result["target"] == "help" then
+  -- Stop here if help or version is required
+  if result["target"] == "help" or result["target"] == "version" then
     return result
   end
   -- An auxiliary to grab all file names into a table
diff --git a/l3build-stdmain.lua b/l3build-stdmain.lua
index dc30ecd..122879a 100644
--- a/l3build-stdmain.lua
+++ b/l3build-stdmain.lua
@@ -82,8 +82,6 @@ function stdmain(target, names)
       errorlevel = call(modules, "uninstall")
     elseif target == "unpack" then
       errorlevel = call(modules, "bundleunpack")
-    elseif target == "version" then
-      version()
     else
       help()
     end
@@ -125,8 +123,6 @@ function stdmain(target, names)
       errorlevel = uninstall()
     elseif target == "unpack" then
       errorlevel = unpack()
-    elseif target == "version" then
-      version()
     else
       help()
     end
diff --git a/l3build.lua b/l3build.lua
index 8b9e6ef..0acb767 100644
--- a/l3build.lua
+++ b/l3build.lua
@@ -103,5 +103,13 @@ if #checkconfigs == 1 and
    end
 end
 
--- Call the main function
+-- Call the main function after filtering special cases
+if options["target"] == "help" then
+  help()
+  exit(0)
+elseif options["target"] == "version" then
+  version()
+  exit(0)
+end
+
 main(options["target"], options["names"])





More information about the latex3-commits mailing list