diff options
| author | V1K1NGbg <victor@ilchev.com> | 2024-08-22 17:49:08 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-10-21 13:30:51 -0300 |
| commit | 4e4aac4c88b1ff427bc9982361d968225d496c4e (patch) | |
| tree | b21f022ed7c22e3017839183aaf65ea5f596f894 /src | |
| parent | 352a9c50ccb8c6e190031d5f9db47e028d408cfd (diff) | |
| download | luarocks-4e4aac4c88b1ff427bc9982361d968225d496c4e.tar.gz luarocks-4e4aac4c88b1ff427bc9982361d968225d496c4e.tar.bz2 luarocks-4e4aac4c88b1ff427bc9982361d968225d496c4e.zip | |
Teal: convert luarocks.admin.cmd.remove
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/admin/cmd/remove.tl (renamed from src/luarocks/admin/cmd/remove.lua) | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/luarocks/admin/cmd/remove.lua b/src/luarocks/admin/cmd/remove.tl index ed7644e0..64b96ef2 100644 --- a/src/luarocks/admin/cmd/remove.lua +++ b/src/luarocks/admin/cmd/remove.tl | |||
| @@ -1,7 +1,8 @@ | |||
| 1 | 1 | ||
| 2 | --- Module implementing the luarocks-admin "remove" command. | 2 | --- Module implementing the luarocks-admin "remove" command. |
| 3 | -- Removes a rock or rockspec from a rocks server. | 3 | -- Removes a rock or rockspec from a rocks server. |
| 4 | local admin_remove = {} | 4 | local record admin_remove |
| 5 | end | ||
| 5 | 6 | ||
| 6 | local cfg = require("luarocks.core.cfg") | 7 | local cfg = require("luarocks.core.cfg") |
| 7 | local util = require("luarocks.util") | 8 | local util = require("luarocks.util") |
| @@ -11,10 +12,14 @@ local fs = require("luarocks.fs") | |||
| 11 | local cache = require("luarocks.admin.cache") | 12 | local cache = require("luarocks.admin.cache") |
| 12 | local index = require("luarocks.admin.index") | 13 | local index = require("luarocks.admin.index") |
| 13 | 14 | ||
| 14 | function admin_remove.add_to_parser(parser) | 15 | local type Parser = require("luarocks.vendor.argparse").Parser |
| 16 | |||
| 17 | local type Args = require("luarocks.core.types.args").Args | ||
| 18 | |||
| 19 | function admin_remove.add_to_parser(parser: Parser) | ||
| 15 | local cmd = parser:command("remove", "Remove a rock or rockspec from a rocks server.", util.see_also()) | 20 | local cmd = parser:command("remove", "Remove a rock or rockspec from a rocks server.", util.see_also()) |
| 16 | 21 | ||
| 17 | cmd:argument("rock", "A local rockspec or rock file.") | 22 | cmd:argument("rocks", "A local rockspec or rock file.") |
| 18 | :args("+") | 23 | :args("+") |
| 19 | 24 | ||
| 20 | cmd:option("--server", "The server to use. If not given, the default server ".. | 25 | cmd:option("--server", "The server to use. If not given, the default server ".. |
| @@ -23,11 +28,7 @@ function admin_remove.add_to_parser(parser) | |||
| 23 | "generation of the updated manifest.") | 28 | "generation of the updated manifest.") |
| 24 | end | 29 | end |
| 25 | 30 | ||
| 26 | local function remove_files_from_server(refresh, rockfiles, server, upload_server) | 31 | local function remove_files_from_server(refresh: boolean, rockfiles: {string}, server: string, upload_server: {string: string}): boolean, string |
| 27 | assert(type(refresh) == "boolean" or not refresh) | ||
| 28 | assert(type(rockfiles) == "table") | ||
| 29 | assert(type(server) == "string") | ||
| 30 | assert(type(upload_server) == "table" or not upload_server) | ||
| 31 | 32 | ||
| 32 | local download_url, login_url = cache.get_server_urls(server, upload_server) | 33 | local download_url, login_url = cache.get_server_urls(server, upload_server) |
| 33 | local at = fs.current_dir() | 34 | local at = fs.current_dir() |
| @@ -85,10 +86,10 @@ local function remove_files_from_server(refresh, rockfiles, server, upload_serve | |||
| 85 | return true | 86 | return true |
| 86 | end | 87 | end |
| 87 | 88 | ||
| 88 | function admin_remove.command(args) | 89 | function admin_remove.command(args: Args): boolean, string |
| 89 | local server, server_table = cache.get_upload_server(args.server) | 90 | local server, server_table, err = cache.get_upload_server(args.server) |
| 90 | if not server then return nil, server_table end | 91 | if not server then return nil, err end |
| 91 | return remove_files_from_server(not args.no_refresh, args.rock, server, server_table) | 92 | return remove_files_from_server(not args.no_refresh, args.rocks, server, server_table) --! |
| 92 | end | 93 | end |
| 93 | 94 | ||
| 94 | 95 | ||
