Skip to content

Commit 469cb66

Browse files
0x501DLeonidVas
authored andcommitted
search: show active label
Show active label if the package is installed and is currently symlinked to run. Example: $ tt search package 2.8.2 2.8.3 [installed] 2.8.4 [active] Closes #181
1 parent bc7f960 commit 469cb66

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

cli/search/search.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"os"
66
"os/exec"
7+
"path"
78
"path/filepath"
89
"strings"
910

@@ -12,6 +13,7 @@ import (
1213
"github.com/tarantool/tt/cli/config"
1314
"github.com/tarantool/tt/cli/configure"
1415
"github.com/tarantool/tt/cli/install_ee"
16+
"github.com/tarantool/tt/cli/util"
1517
"github.com/tarantool/tt/cli/version"
1618
)
1719

@@ -136,10 +138,23 @@ func GetVersionsFromGitLocal(repo string) ([]version.Version, error) {
136138
return versions, nil
137139
}
138140

139-
// printVersion prints the version and label if the package is installed.
141+
// printVersion prints the version and labels:
142+
// * if the package is installed: [installed]
143+
// * if the package is installed and in use: [active]
140144
func printVersion(bindir string, program string, version string) {
141145
if _, err := os.Stat(filepath.Join(bindir, program+VersionFsSeparator+version)); err == nil {
142-
fmt.Printf("%s [installed]\n", version)
146+
target := ""
147+
if program == "tarantool-ee" {
148+
target, _ = util.ResolveSymlink(filepath.Join(bindir, "tarantool"))
149+
} else {
150+
target, _ = util.ResolveSymlink(filepath.Join(bindir, program))
151+
}
152+
153+
if path.Base(target) == program+VersionFsSeparator+version {
154+
fmt.Printf("%s [active]\n", version)
155+
} else {
156+
fmt.Printf("%s [installed]\n", version)
157+
}
143158
} else {
144159
fmt.Println(version)
145160
}

0 commit comments

Comments
 (0)