Skip to content

Commit

Permalink
Remove use-lj and use-rocks commands
Browse files Browse the repository at this point in the history
  • Loading branch information
mah0x211 committed Apr 5, 2024
1 parent 42d8720 commit 3718fe4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 41 deletions.
2 changes: 0 additions & 2 deletions help.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ Commands:
ls List installed versions
install <version> <opt...> Install and use a <version> of lua
use <version> Use a <version> of lua
use-lj <version> Use a <version> of luajit
use-rocks <version> Use a <version> of luajit
Note:
The <version> specifier of the above commands can be specified as follows;
Expand Down
11 changes: 2 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ ERROR: the required directory does not exists.

func CheckLuaRocksRootDir() {
if LuaRocksCfg.RootDir == "" {
fatalf("%q does not exist.\nplease run `lenv use <ver>` or `lenv use-lj <ver>` before installing or uninstalling luarocks", CurrentDir)
fatalf("%q does not exist.\nplease run `lenv use <ver>` before installing or uninstalling luarocks", CurrentDir)
}
}

Expand Down Expand Up @@ -359,14 +359,7 @@ func start() {
CmdUninstall(LuaRocksCfg, argv[1:])

case "use":
CmdUse(LuaCfg, argv[1:])

case "use-lj":
CmdUse(LuaJitCfg, argv[1:])

case "use-rocks":
CheckLuaRocksRootDir()
CmdUse(LuaRocksCfg, argv[1:])
CmdUse(argv[1:])

default:
CmdHelp(1, "unknown command %q", argv[0])
Expand Down
38 changes: 8 additions & 30 deletions use.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,35 +48,13 @@ func UseInstalledVersion(cfg *TargetConfig, ver string) {
fatalf("%s version %q is not installed", cfg.Name, ver)
}

func CmdUse(cfg *TargetConfig, opts []string) {
// check target version
if len(opts) == 0 || (cfg != LuaRocksCfg && opts[0] == ":") {
CmdHelp(1, "no version specified")
}
ver := opts[0]

// check :<luarocks-version>
var rocksVer string
if cfg != LuaRocksCfg {
if delim := strings.Index(ver, ":"); delim != -1 {
rocksVer = ver[delim+1:]
ver = ver[:delim]
}
}

var verItem *VerItem
if len(ver) > 0 {
verItem = PickTargetVersionItem(cfg, ver)
}
var rocksItem *VerItem
if len(rocksVer) > 0 {
rocksItem = PickTargetVersionItem(LuaRocksCfg, rocksVer)
}

if verItem != nil {
UseInstalledVersion(cfg, verItem.Ver)
}
if rocksItem != nil {
UseInstalledVersion(LuaRocksCfg, rocksItem.Ver)
func CmdUse(opts []string) {
target := PickTargetVersion(opts[0])
if target.Lua != nil {
UseInstalledVersion(target.Lua.Config, target.Lua.Version.Ver)
}
if target.LuaRocks != nil {
CheckLuaRocksRootDir()
UseInstalledVersion(target.LuaRocks.Config, target.LuaRocks.Version.Ver)
}
}

0 comments on commit 3718fe4

Please sign in to comment.