Skip to content

Commit 2fc2a1e

Browse files
committed
splat.moon: specify the modules to autoload with -l
1 parent 0f44808 commit 2fc2a1e

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

bin/splat.moon

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
-- concatenate a collection of lua modules into one
44

55
require "lfs"
6+
require "alt_getopt"
67

78
import insert, concat from table
8-
import dump from require "moonscript.util"
9+
import dump, split from require "moonscript.util"
910

10-
if not arg[1]
11-
print "usage: splat directory [directories...]"
11+
opts, ind = alt_getopt.get_opts arg, "l:", {
12+
load: "l"
13+
}
14+
15+
if not arg[ind]
16+
print "usage: splat [-l module_names] directory [directories...]"
1217
os.exit!
1318

14-
dirs = [a for a in *arg[,]]
19+
dirs = [a for a in *arg[ind,]]
1520

1621
normalize = (path) ->
1722
path\match("(.-)/*$").."/"
@@ -68,8 +73,8 @@ for dir in *dirs
6873
name = base
6974
write_module name, content
7075

71-
for dir in *dirs
72-
module_name = dir\gsub("/", ".")\gsub("%.$", "")
73-
if modules[module_name]
74-
print ([[package.preload["%s"]()]])\format module_name
76+
if opts.l
77+
for module_name in *split opts.l, ","
78+
if modules[module_name]
79+
print ([[package.preload["%s"]()]])\format module_name
7580

0 commit comments

Comments
 (0)