Skip to content

Commit 54a9b78

Browse files
committed
Remove uninstall-lj and uninstall-rocks commands
1 parent d8a500d commit 54a9b78

File tree

6 files changed

+19
-9
lines changed

6 files changed

+19
-9
lines changed

help.go

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ Commands:
6363
If the version of luarocks is specified along with the version of lua, the
6464
operation will target the specified version of the lua environment.
6565
Otherwise, the operation will target the current lua environment.
66+
67+
In the case of the 'uninstall' command, the version specifier must match the
68+
target version exactly. Also, if the version of luarocks is specified along
69+
with the version of lua, the version specifier of luarocks is ignored.
6670
`)
6771
osExit(rc)
6872
}

install.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ func doInstall(cfg *TargetConfig, item *VerItem, opts []string) {
438438
}
439439

440440
func CmdInstall(opts []string) {
441-
target := PickTargetVersion(opts[0])
441+
target := PickTargetVersion(opts[0], false)
442442
if target.Lua != nil {
443443
doInstall(target.Lua.Config, target.Lua.Version, opts[1:])
444444
}

main.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ type TargetVersion struct {
273273
LuaRocks *Target
274274
}
275275

276-
func PickTargetVersion(vers string) *TargetVersion {
276+
func PickTargetVersion(vers string, exactMatch bool) *TargetVersion {
277277
// check target version
278278
if len(vers) == 0 || vers == ":" {
279279
CmdHelp(1, "no version specified")
@@ -292,21 +292,21 @@ func PickTargetVersion(vers string) *TargetVersion {
292292
// if `lj-' prefix is specified, then the target is LuaJIT version
293293
target.Lua = &Target{
294294
Config: LuaJitCfg,
295-
Version: PickTargetVersionItem(LuaJitCfg, vers[3:]),
295+
Version: PickTargetVersionItem(LuaJitCfg, vers[3:], exactMatch),
296296
}
297297
} else {
298298
// otherwise the target is Lua version.
299299
target.Lua = &Target{
300300
Config: LuaCfg,
301-
Version: PickTargetVersionItem(LuaCfg, vers),
301+
Version: PickTargetVersionItem(LuaCfg, vers, exactMatch),
302302
}
303303
}
304304
}
305305

306306
if len(rocksVer) > 0 {
307307
target.LuaRocks = &Target{
308308
Config: LuaRocksCfg,
309-
Version: PickTargetVersionItem(LuaRocksCfg, rocksVer),
309+
Version: PickTargetVersionItem(LuaRocksCfg, rocksVer, exactMatch),
310310
}
311311
}
312312

uninstall.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func uninstall(t *Target) {
2323
}
2424

2525
func CmdUninstall(opts []string) {
26-
target := PickTargetVersion(opts[0])
26+
target := PickTargetVersion(opts[0], true)
2727

2828
// uninstall the specified version of lua
2929
if target.Lua != nil {

use.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func UseInstalledVersion(cfg *TargetConfig, ver string) {
4949
}
5050

5151
func CmdUse(opts []string) {
52-
target := PickTargetVersion(opts[0])
52+
target := PickTargetVersion(opts[0], false)
5353
if target.Lua != nil {
5454
UseInstalledVersion(target.Lua.Config, target.Lua.Version.Ver)
5555
}

vers.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,20 @@ func ListTargetVersions(cfg *TargetConfig) string {
282282
return b.String()
283283
}
284284

285-
func PickTargetVersionItem(cfg *TargetConfig, ver string) *VerItem {
285+
func PickTargetVersionItem(cfg *TargetConfig, ver string, exactMatch bool) *VerItem {
286286
print("check %s version %q definition ... ", cfg.Name, ver)
287287
vers, err := NewVersionsFromFile(cfg.VersionFile)
288288
if err != nil {
289289
fatalf("failed to read version file %q: %v", cfg.VersionFile, err)
290290
}
291291

292-
item := vers.PickItem(ver)
292+
var item *VerItem
293+
if exactMatch {
294+
item = vers.GetItem(ver)
295+
} else {
296+
item = vers.PickItem(ver)
297+
}
298+
293299
if item == nil {
294300
printf("not found")
295301
fatalf("%s version %q does not defined in %q\n%s", cfg.Name, ver, cfg.VersionFile, ListTargetVersions(cfg))

0 commit comments

Comments
 (0)