Skip to content

Commit 0ebeea6

Browse files
committed
xim: add --use for use installed version directly
Signed-off-by: sunrisepeak <speakshen@163.com>
1 parent cdd92b3 commit 0ebeea6

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

core/xim/CmdProcessor.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,9 @@ function CmdProcessor:install()
269269
if self._pm_executor:install(xpkg) then
270270
self:_restart_tips()
271271
cprint("[xlings:xim]: ${green bright}%s${clear} - installed", self.target)
272+
if self.cmds.sys_use then
273+
self._pm_executor:use()
274+
end
272275
index_manager.status_changed_pkg[self.target] = {installed = true}
273276
else
274277
self:_feedback()
@@ -350,7 +353,8 @@ function CmdProcessor:update()
350353
cprint("[xlings:xim]: ${bright}try to update [ %s ] to latest version...${clear}", self._input_target)
351354
new(self._input_target .. "@latest", {
352355
yes = true,
353-
disable_info = true
356+
disable_info = true,
357+
sys_use = true
354358
}):run()
355359
end
356360
end

core/xim/pm/PkgManagerExecutor.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
-- runtime dir is cachedir
22

33
import("xim.base.runtime")
4+
import("xim.base.xvm")
45
import("xim.pm.XPkgManager")
56

67
local PkgManagerExecutor = {}
@@ -71,6 +72,10 @@ function PkgManagerExecutor:install()
7172
return true
7273
end
7374

75+
function PkgManagerExecutor:use()
76+
xvm.use(self._pkg.name, self._pkg.version)
77+
end
78+
7479
function PkgManagerExecutor:_config()
7580
-- only for xpm, and called in install
7681
if self._pkg.hooks.config then

core/xim/xim.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function _input_process(args)
3232
["--add-xpkg"] = false, -- --add-xpkg (string)
3333
["--add-indexrepo"] = false, -- --add-indexrepo (string)
3434
["--xpkg-args"] = false, -- --xpkg-args (string)
35+
["--use"] = false, -- --use (string)
3536
}
3637

3738
if #args > 0 and args[1]:sub(1, 1) ~= '-' then
@@ -74,6 +75,7 @@ function _input_process(args)
7475
sysxim_args = args, -- is table, xim's original args
7576

7677
info_json = boolean_cmds["--info-json"],
78+
sys_use = kv_cmds["--use"],
7779
}
7880

7981
return main_target, cmds

0 commit comments

Comments
 (0)