diff options
| author | ruki <[email protected]> | 2021-04-15 22:40:06 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-04-15 22:40:06 +0800 |
| commit | 73ec474ac3abed46e6e9a586231ff65dd2145bcc (patch) | |
| tree | 1324d103900099f3809a41a5c6511e5c3db90494 | |
| parent | 4309e9b5d443ad3f4bf3b6b5c444b6668f1781a7 (diff) | |
add xrepo env shell
| -rw-r--r-- | xmake/modules/private/xrepo/action/env.lua | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/xmake/modules/private/xrepo/action/env.lua b/xmake/modules/private/xrepo/action/env.lua index 703c497fc..eaedd1d7c 100644 --- a/xmake/modules/private/xrepo/action/env.lua +++ b/xmake/modules/private/xrepo/action/env.lua @@ -22,6 +22,7 @@ import("core.base.option") import("core.base.task") import("core.project.config") +import("lib.detect.find_tool") import("private.action.require.impl.package") import("private.action.require.impl.utils.get_requires") @@ -55,6 +56,8 @@ function menu_options() {nil, "program", "v", nil, "Set the program name to be run", "e.g.", " - xrepo env", + " - xrepo env bash", + " - xrepo env shell (it will load bash/sh/cmd automatically)", " - xrepo env python", " - xrepo env -p android luajit xx.lua"}, {nil, "arguments", "vs", nil, "Set the program arguments to be run"} @@ -229,6 +232,18 @@ function _package_getenvs() return envs end +-- run shell +function _run_shell(envs) + local shell = find_tool("bash") or find_tool("sh") + if shell then + local prompt = "xrepo> " + os.execv(shell.program, option.get("arguments"), {envs = table.join({PS1 = prompt}, envs)}) + elseif is_host("windows") then + local prompt = "xrepo$G " + os.execv("cmd", table.join({"/k", "prompt " .. prompt}, option.get("arguments")), {envs = envs}) + end +end + -- main entry function main() local envs = _package_getenvs() @@ -237,7 +252,11 @@ function main() if envs and envs.PATH then os.setenv("PATH", envs.PATH) end - os.execv(program, option.get("arguments"), {envs = envs}) + if program == "shell" then + _run_shell(envs) + else + os.execv(program, option.get("arguments"), {envs = envs}) + end else print(envs) end |
