[latex3-commits] [git/LaTeX3-latex3-l3build] experimental: Target detection refactoring. (5e597cd)

Paulo Roberto Massa Cereda cereda.paulo at gmail.com
Wed Jul 31 21:02:39 CEST 2019


Repository : https://github.com/latex3/l3build
On branch  : experimental
Link       : https://github.com/latex3/l3build/commit/5e597cda7e80bb9243fc6e0611af45332b9050a3

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

commit 5e597cda7e80bb9243fc6e0611af45332b9050a3
Author: Paulo Roberto Massa Cereda <cereda.paulo at gmail.com>
Date:   Wed Jul 31 16:02:39 2019 -0300

    Target detection refactoring.
    
    - Removed old target detection, based on positional arguments.
    - Target detection now relies on the first non-option element
      found in the command line arguments.


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

5e597cda7e80bb9243fc6e0611af45332b9050a3
 l3build-arguments.lua | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/l3build-arguments.lua b/l3build-arguments.lua
index 6c8f238..0cc0d4f 100644
--- a/l3build-arguments.lua
+++ b/l3build-arguments.lua
@@ -117,15 +117,6 @@ function l3args.argparse(targets, options, arguments)
   -- target, initially set to true
   issues['target'] = true
 
-  -- handle the positional target
-  if #arguments > 0 then
-    local target = utils.remove(arguments, 1)
-    if l3args.exists(targets, target) then
-      keys['target'] = target
-      issues['target'] = false
-    end
-  end
-
   for _, v in utils.ipairs(arguments) do
 
     -- look for a short option (no separator)
@@ -438,6 +429,25 @@ function l3args.argparse(targets, options, arguments)
     end
   end
 
+  -- potential target extraction, check
+  -- whether the remainder is not empty
+  if #keys['remainder'] > 0 then
+
+    -- verify if the first element in the
+    -- remainder tablle is a valid target
+    if l3args.exists(targets, keys['remainder'][1]) then
+
+      -- the first element is a valid key,
+      -- so remove it from the remainder
+      -- table and update the target key
+      keys['target'] = utils.remove(keys['remainder'], 1)
+
+      -- there is no issue regarding
+      -- an unknown target, so update
+      issues['target'] = false
+    end
+  end
+
   -- return the key/value table and
   -- the potential issues
   return keys, issues





More information about the latex3-commits mailing list