diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2024-02-18 20:34:33 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-02-19 08:22:54 -0300 |
| commit | b1fd49273ed6691283f55eeb3f318214618e3f18 (patch) | |
| tree | 1a0f58e21ef58c3b0b0f6eda5587f7a7a0f9becc /src | |
| parent | f67bf0e2bb0c8d136774ef138dbd8cce365bf9b3 (diff) | |
| download | luarocks-b1fd49273ed6691283f55eeb3f318214618e3f18.tar.gz luarocks-b1fd49273ed6691283f55eeb3f318214618e3f18.tar.bz2 luarocks-b1fd49273ed6691283f55eeb3f318214618e3f18.zip | |
feat(path): add --full flag for --lr-path and --lr-cpath
By default, `--lr-path` and `--lr-cpath` only include the paths derived by the
LuaRocks rocks_trees. Using `--full` includes any other components defined in
your system's package.(c)path, either via the running interpreter's default
paths or via `LUA_(C)PATH(_5_x)` environment variables (in short, using
`--full` produces the same lists as shown in the shell outputs of `luarocks
path`.
Closes #1351.
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/cmd/path.lua | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/src/luarocks/cmd/path.lua b/src/luarocks/cmd/path.lua index 9b6fee71..ac78724d 100644 --- a/src/luarocks/cmd/path.lua +++ b/src/luarocks/cmd/path.lua | |||
| @@ -22,8 +22,15 @@ And on Windows: | |||
| 22 | cmd:flag("--no-bin", "Do not export the PATH variable.") | 22 | cmd:flag("--no-bin", "Do not export the PATH variable.") |
| 23 | cmd:flag("--append", "Appends the paths to the existing paths. Default is ".. | 23 | cmd:flag("--append", "Appends the paths to the existing paths. Default is ".. |
| 24 | "to prefix the LR paths to the existing paths.") | 24 | "to prefix the LR paths to the existing paths.") |
| 25 | cmd:flag("--lr-path", "Exports the Lua path (not formatted as shell command).") | 25 | cmd:flag("--lr-path", "Prints Lua path components defined by the configured rocks trees " .. |
| 26 | cmd:flag("--lr-cpath", "Exports the Lua cpath (not formatted as shell command).") | 26 | "(not formatted as a shell command)") |
| 27 | cmd:flag("--lr-cpath", "Prints Lua cpath components defined by the configured rocks trees " .. | ||
| 28 | "(not formatted as a shell command)") | ||
| 29 | cmd:flag("--full", "By default, --lr-path and --lr-cpath only include the paths " .. | ||
| 30 | "derived by the LuaRocks rocks_trees. Using --full includes any other components " .. | ||
| 31 | "defined in your system's package.(c)path, either via the running interpreter's " .. | ||
| 32 | "default paths or via LUA_(C)PATH(_5_x) environment variables (in short, using " .. | ||
| 33 | "--full produces the same lists as shown in the shell outputs of 'luarocks path').") | ||
| 27 | cmd:flag("--lr-bin", "Exports the system path (not formatted as shell command).") | 34 | cmd:flag("--lr-bin", "Exports the system path (not formatted as shell command).") |
| 28 | cmd:flag("--bin"):hidden(true) | 35 | cmd:flag("--bin"):hidden(true) |
| 29 | end | 36 | end |
| @@ -34,6 +41,23 @@ function path_cmd.command(args) | |||
| 34 | local lr_path, lr_cpath, lr_bin = cfg.package_paths(args.tree) | 41 | local lr_path, lr_cpath, lr_bin = cfg.package_paths(args.tree) |
| 35 | local path_sep = cfg.export_path_separator | 42 | local path_sep = cfg.export_path_separator |
| 36 | 43 | ||
| 44 | local full_list = ((not args.lr_path) and (not args.lr_cpath) and (not args.lr_bin)) | ||
| 45 | or args.full | ||
| 46 | |||
| 47 | local clean_path = util.cleanup_path(os.getenv("PATH") or "", path_sep, nil, true) | ||
| 48 | |||
| 49 | if full_list then | ||
| 50 | if args.append then | ||
| 51 | lr_path = package.path .. ";" .. lr_path | ||
| 52 | lr_cpath = package.cpath .. ";" .. lr_cpath | ||
| 53 | lr_bin = clean_path .. path_sep .. lr_bin | ||
| 54 | else | ||
| 55 | lr_path = lr_path.. ";" .. package.path | ||
| 56 | lr_cpath = lr_cpath .. ";" .. package.cpath | ||
| 57 | lr_bin = lr_bin .. path_sep .. clean_path | ||
| 58 | end | ||
| 59 | end | ||
| 60 | |||
| 37 | if args.lr_path then | 61 | if args.lr_path then |
| 38 | util.printout(util.cleanup_path(lr_path, ';', cfg.lua_version, true)) | 62 | util.printout(util.cleanup_path(lr_path, ';', cfg.lua_version, true)) |
| 39 | return true | 63 | return true |
| @@ -45,18 +69,6 @@ function path_cmd.command(args) | |||
| 45 | return true | 69 | return true |
| 46 | end | 70 | end |
| 47 | 71 | ||
| 48 | local clean_path = util.cleanup_path(os.getenv("PATH") or "", path_sep, nil, true) | ||
| 49 | |||
| 50 | if args.append then | ||
| 51 | lr_path = package.path .. ";" .. lr_path | ||
| 52 | lr_cpath = package.cpath .. ";" .. lr_cpath | ||
| 53 | lr_bin = clean_path .. path_sep .. lr_bin | ||
| 54 | else | ||
| 55 | lr_path = lr_path.. ";" .. package.path | ||
| 56 | lr_cpath = lr_cpath .. ";" .. package.cpath | ||
| 57 | lr_bin = lr_bin .. path_sep .. clean_path | ||
| 58 | end | ||
| 59 | |||
| 60 | local lpath_var, lcpath_var = util.lua_path_variables() | 72 | local lpath_var, lcpath_var = util.lua_path_variables() |
| 61 | 73 | ||
| 62 | util.printout(fs.export_cmd(lpath_var, util.cleanup_path(lr_path, ';', cfg.lua_version, args.append))) | 74 | util.printout(fs.export_cmd(lpath_var, util.cleanup_path(lr_path, ';', cfg.lua_version, args.append))) |
