From 2b14ed6d3906b436a4a58683385001a3bfedb117 Mon Sep 17 00:00:00 2001 From: V1K1NGbg Date: Thu, 22 Aug 2024 17:49:07 -0300 Subject: Teal: convert luarocks.admin.cmd.refresh_cache --- src/luarocks/admin/cmd/refresh_cache.lua | 31 --------------------------- src/luarocks/admin/cmd/refresh_cache.tl | 36 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 31 deletions(-) delete mode 100644 src/luarocks/admin/cmd/refresh_cache.lua create mode 100644 src/luarocks/admin/cmd/refresh_cache.tl diff --git a/src/luarocks/admin/cmd/refresh_cache.lua b/src/luarocks/admin/cmd/refresh_cache.lua deleted file mode 100644 index f8d51893..00000000 --- a/src/luarocks/admin/cmd/refresh_cache.lua +++ /dev/null @@ -1,31 +0,0 @@ - ---- Module implementing the luarocks-admin "refresh_cache" command. -local refresh_cache = {} - -local cfg = require("luarocks.core.cfg") -local util = require("luarocks.util") -local cache = require("luarocks.admin.cache") - -function refresh_cache.add_to_parser(parser) - local cmd = parser:command("refresh_cache", "Refresh local cache of a remote rocks server.", util.see_also()) - - cmd:option("--from", "The server to use. If not given, the default server ".. - "set in the upload_server variable from the configuration file is used instead.") - :argname("") -end - -function refresh_cache.command(args) - local server, upload_server = cache.get_upload_server(args.server) - if not server then return nil, upload_server end - local download_url = cache.get_server_urls(server, upload_server) - - local ok, err = cache.refresh_local_cache(download_url, cfg.upload_user, cfg.upload_password) - if not ok then - return nil, err - else - return true - end -end - - -return refresh_cache diff --git a/src/luarocks/admin/cmd/refresh_cache.tl b/src/luarocks/admin/cmd/refresh_cache.tl new file mode 100644 index 00000000..07480159 --- /dev/null +++ b/src/luarocks/admin/cmd/refresh_cache.tl @@ -0,0 +1,36 @@ + +--- Module implementing the luarocks-admin "refresh_cache" command. +local record refresh_cache +end + +local cfg = require("luarocks.core.cfg") +local util = require("luarocks.util") +local cache = require("luarocks.admin.cache") + +local type Parser = require("luarocks.vendor.argparse").Parser + +local type Args = require("luarocks.core.types.args").Args + +function refresh_cache.add_to_parser(parser: Parser) + local cmd = parser:command("refresh_cache", "Refresh local cache of a remote rocks server.", util.see_also()) + + cmd:option("--from", "The server to use. If not given, the default server ".. + "set in the upload_server variable from the configuration file is used instead.") + :argname("") +end + +function refresh_cache.command(args: Args): boolean, string + local server, upload_server, err = cache.get_upload_server(args.server) + if not server then return nil, err end + local download_url = cache.get_server_urls(server, upload_server) + + local ok, err = cache.refresh_local_cache(download_url, cfg.upload_user, cfg.upload_password) + if not ok then + return nil, err + else + return true + end +end + + +return refresh_cache -- cgit v1.2.3-55-g6feb