From f6000e9050c4e0d3b9c06809802abdefb7d01bb2 Mon Sep 17 00:00:00 2001 From: V1K1NGbg Date: Thu, 22 Aug 2024 17:49:02 -0300 Subject: Teal: convert luarocks.cmd.pack --- src/luarocks/cmd/pack.lua | 36 ------------------------------------ src/luarocks/cmd/pack.tl | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 36 deletions(-) delete mode 100644 src/luarocks/cmd/pack.lua create mode 100644 src/luarocks/cmd/pack.tl diff --git a/src/luarocks/cmd/pack.lua b/src/luarocks/cmd/pack.lua deleted file mode 100644 index 29a43e7b..00000000 --- a/src/luarocks/cmd/pack.lua +++ /dev/null @@ -1,36 +0,0 @@ - ---- 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 diff --git a/src/luarocks/cmd/pack.tl b/src/luarocks/cmd/pack.tl new file mode 100644 index 00000000..750ae9c9 --- /dev/null +++ b/src/luarocks/cmd/pack.tl @@ -0,0 +1,41 @@ + +--- Module implementing the LuaRocks "pack" command. +-- Creates a rock, packing sources or binaries. +local record cmd_pack +end + +local util = require("luarocks.util") +local pack = require("luarocks.pack") +local queries = require("luarocks.queries") + +local type Parser = require("luarocks.vendor.argparse").Parser + +local type Args = require("luarocks.core.types.args").Args + +function cmd_pack.add_to_parser(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: Args): boolean, string + local file, err: string, string + 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 -- cgit v1.2.3-55-g6feb