summaryrefslogtreecommitdiff
path: root/src/luarocks/cmd/pack.lua
diff options
context:
space:
mode:
authorMike Vink <mike@pionative.com>2025-02-03 21:29:42 +0100
committerMike Vink <mike@pionative.com>2025-02-03 21:29:42 +0100
commit5155816b7b925dec5d5feb1568b1d7ceb00938b9 (patch)
treedeca28ea15e79f6f804c3d90d2ba757881638af5 /src/luarocks/cmd/pack.lua
fetch tarballHEADmaster
Diffstat (limited to 'src/luarocks/cmd/pack.lua')
-rw-r--r--src/luarocks/cmd/pack.lua36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/luarocks/cmd/pack.lua b/src/luarocks/cmd/pack.lua
new file mode 100644
index 0000000..29a43e7
--- /dev/null
+++ b/src/luarocks/cmd/pack.lua
@@ -0,0 +1,36 @@
+
+--- Module implementing the LuaRocks "pack" command.
+-- Creates a rock, packing sources or binaries.
+local cmd_pack = {}
+
+local util = require("luarocks.util")
+local pack = require("luarocks.pack")
+local queries = require("luarocks.queries")
+
+function cmd_pack.add_to_parser(parser)
+ local cmd = parser:command("pack", "Create a rock, packing sources or binaries.", util.see_also())
+
+ cmd:argument("rock", "A rockspec file, for creating a source rock, or the "..
+ "name of an installed package, for creating a binary rock.")
+ :action(util.namespaced_name_action)
+ cmd:argument("version", "A version may be given if the first argument is a rock name.")
+ :args("?")
+
+ cmd:flag("--sign", "Produce a signature file as well.")
+end
+
+--- Driver function for the "pack" command.
+-- @return boolean or (nil, string): true if successful or nil followed
+-- by an error message.
+function cmd_pack.command(args)
+ local file, err
+ if args.rock:match(".*%.rockspec") then
+ file, err = pack.pack_source_rock(args.rock)
+ else
+ local query = queries.new(args.rock, args.namespace, args.version)
+ file, err = pack.pack_installed_rock(query, args.tree)
+ end
+ return pack.report_and_sign_local_file(file, err, args.sign)
+end
+
+return cmd_pack