mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-09 07:39:21 +00:00
feat(lua): Some aliases for Target-commands
This commit is contained in:
+11
-4
@@ -36,19 +36,26 @@ rtorrent["autocall"] = setmetatable({}, mt)
|
|||||||
|
|
||||||
-- Target-object
|
-- Target-object
|
||||||
-- Sets first argment for Autocall, for commands that require target.
|
-- Sets first argment for Autocall, for commands that require target.
|
||||||
|
-- Second argument allows to add prefix to command.
|
||||||
-- Allows syntax like:
|
-- Allows syntax like:
|
||||||
-- - `rtorrent.Target("some_infohash").d.name()` or
|
-- - `rtorrent.Target("some_infohash").d.name()` or
|
||||||
-- - `rtorrent.Target:new("some_infohash").d.name()`
|
-- - `rtorrent.Target:new("some_infohash").d.name()`
|
||||||
-- Also can be stored as variable
|
-- Also can be stored as variable
|
||||||
local Target = setmetatable({
|
local Target = setmetatable({
|
||||||
new = function (self, target)
|
new = function (self, target, prefix)
|
||||||
return self(target)
|
return self(target, prefix)
|
||||||
end;
|
end;
|
||||||
}, {
|
}, {
|
||||||
__call = function (self, target)
|
__call = function (self, target, prefix)
|
||||||
return setmetatable({__target=target}, mt)
|
return setmetatable(
|
||||||
|
{__namestack={prefix}, __target=target}, mt)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
rtorrent["Target"] = Target
|
rtorrent["Target"] = Target
|
||||||
|
|
||||||
|
-- Some aliases for Target-commands
|
||||||
|
for i, p in ipairs({ "d", "f", "p", "t", "load" }) do
|
||||||
|
rtorrent[p] = function (target) return Target(target, p) end
|
||||||
|
end
|
||||||
|
|
||||||
return rtorrent
|
return rtorrent
|
||||||
|
|||||||
Reference in New Issue
Block a user