From 54a9b7850cd977774302e5796b0242c2dbfff17c Mon Sep 17 00:00:00 2001 From: mah0x211 Date: Fri, 5 Apr 2024 13:56:59 +0900 Subject: [PATCH] Remove uninstall-lj and uninstall-rocks commands --- help.go | 4 ++++ install.go | 2 +- main.go | 8 ++++---- uninstall.go | 2 +- use.go | 2 +- vers.go | 10 ++++++++-- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/help.go b/help.go index ec56982..8a936b3 100644 --- a/help.go +++ b/help.go @@ -63,6 +63,10 @@ Commands: If the version of luarocks is specified along with the version of lua, the operation will target the specified version of the lua environment. Otherwise, the operation will target the current lua environment. + + In the case of the 'uninstall' command, the version specifier must match the + target version exactly. Also, if the version of luarocks is specified along + with the version of lua, the version specifier of luarocks is ignored. `) osExit(rc) } diff --git a/install.go b/install.go index 3c3dc89..9b76db2 100644 --- a/install.go +++ b/install.go @@ -438,7 +438,7 @@ func doInstall(cfg *TargetConfig, item *VerItem, opts []string) { } func CmdInstall(opts []string) { - target := PickTargetVersion(opts[0]) + target := PickTargetVersion(opts[0], false) if target.Lua != nil { doInstall(target.Lua.Config, target.Lua.Version, opts[1:]) } diff --git a/main.go b/main.go index eadf402..e953ce0 100644 --- a/main.go +++ b/main.go @@ -273,7 +273,7 @@ type TargetVersion struct { LuaRocks *Target } -func PickTargetVersion(vers string) *TargetVersion { +func PickTargetVersion(vers string, exactMatch bool) *TargetVersion { // check target version if len(vers) == 0 || vers == ":" { CmdHelp(1, "no version specified") @@ -292,13 +292,13 @@ func PickTargetVersion(vers string) *TargetVersion { // if `lj-' prefix is specified, then the target is LuaJIT version target.Lua = &Target{ Config: LuaJitCfg, - Version: PickTargetVersionItem(LuaJitCfg, vers[3:]), + Version: PickTargetVersionItem(LuaJitCfg, vers[3:], exactMatch), } } else { // otherwise the target is Lua version. target.Lua = &Target{ Config: LuaCfg, - Version: PickTargetVersionItem(LuaCfg, vers), + Version: PickTargetVersionItem(LuaCfg, vers, exactMatch), } } } @@ -306,7 +306,7 @@ func PickTargetVersion(vers string) *TargetVersion { if len(rocksVer) > 0 { target.LuaRocks = &Target{ Config: LuaRocksCfg, - Version: PickTargetVersionItem(LuaRocksCfg, rocksVer), + Version: PickTargetVersionItem(LuaRocksCfg, rocksVer, exactMatch), } } diff --git a/uninstall.go b/uninstall.go index 6648d07..e8c5757 100644 --- a/uninstall.go +++ b/uninstall.go @@ -23,7 +23,7 @@ func uninstall(t *Target) { } func CmdUninstall(opts []string) { - target := PickTargetVersion(opts[0]) + target := PickTargetVersion(opts[0], true) // uninstall the specified version of lua if target.Lua != nil { diff --git a/use.go b/use.go index eb95121..ca6c101 100644 --- a/use.go +++ b/use.go @@ -49,7 +49,7 @@ func UseInstalledVersion(cfg *TargetConfig, ver string) { } func CmdUse(opts []string) { - target := PickTargetVersion(opts[0]) + target := PickTargetVersion(opts[0], false) if target.Lua != nil { UseInstalledVersion(target.Lua.Config, target.Lua.Version.Ver) } diff --git a/vers.go b/vers.go index d5932f8..1a12de1 100644 --- a/vers.go +++ b/vers.go @@ -282,14 +282,20 @@ func ListTargetVersions(cfg *TargetConfig) string { return b.String() } -func PickTargetVersionItem(cfg *TargetConfig, ver string) *VerItem { +func PickTargetVersionItem(cfg *TargetConfig, ver string, exactMatch bool) *VerItem { print("check %s version %q definition ... ", cfg.Name, ver) vers, err := NewVersionsFromFile(cfg.VersionFile) if err != nil { fatalf("failed to read version file %q: %v", cfg.VersionFile, err) } - item := vers.PickItem(ver) + var item *VerItem + if exactMatch { + item = vers.GetItem(ver) + } else { + item = vers.PickItem(ver) + } + if item == nil { printf("not found") fatalf("%s version %q does not defined in %q\n%s", cfg.Name, ver, cfg.VersionFile, ListTargetVersions(cfg))