diff --git a/cmd/vmr/cli/cli.go b/cmd/vmr/cli/cli.go index b2d7b58..02aa1b7 100644 --- a/cmd/vmr/cli/cli.go +++ b/cmd/vmr/cli/cli.go @@ -63,6 +63,7 @@ func (c *Cli) initiate() { c.rootCmd.AddCommand(vcli.ShowSDKCmd) c.rootCmd.AddCommand(vcli.SearchVersionsCmd) c.rootCmd.AddCommand(vcli.ShowInstalledCmd) + c.rootCmd.AddCommand(vcli.ShowInstalledSDKs) c.rootCmd.AddCommand(vcli.UninstallVersionCmd) } diff --git a/cmd/vmr/cli/use.go b/cmd/vmr/cli/use.go index aa25790..8c1d79e 100644 --- a/cmd/vmr/cli/use.go +++ b/cmd/vmr/cli/use.go @@ -26,6 +26,7 @@ var useCmd = &cobra.Command{ if ok, _ := cmd.Flags().GetBool("enable-locked-version"); ok { l := installer.NewVLocker() l.HookForCdCommand() + return } if len(args) == 0 { diff --git a/cmd/vmr/cli/vcli/local.go b/cmd/vmr/cli/vcli/local.go index efa1b85..dcebe65 100644 --- a/cmd/vmr/cli/vcli/local.go +++ b/cmd/vmr/cli/vcli/local.go @@ -25,3 +25,15 @@ var ShowInstalledCmd = &cobra.Command{ l.Show() }, } + +var ShowInstalledSDKs = &cobra.Command{ + Use: "installed-sdks", + Aliases: []string{"in"}, + GroupID: GroupID, + Short: "Shows installed SDKs.", + Long: "Example: vmr in.", + Run: func(cmd *cobra.Command, args []string) { + l := cliui.NewSDKSearcher() + l.PrintInstalledSDKs() + }, +} diff --git a/internal/tui/cliui/sdk_list.go b/internal/tui/cliui/sdk_list.go index e58d6d6..8564969 100644 --- a/internal/tui/cliui/sdk_list.go +++ b/internal/tui/cliui/sdk_list.go @@ -98,6 +98,26 @@ func (v *SDKSearcher) ShowInstalledOnly() (nextEvent, selectedItem string) { return } +func (v *SDKSearcher) PrintInstalledSDKs() { + v.SdkList = download.GetSDKList() + rows := download.GetSDKSortedRows(v.SdkList) + + installedRows := []table.Row{} + for _, r := range rows { + if install.IsSDKInstalledByVMR(r[0]) { + installedRows = append(installedRows, r) + } + } + if len(installedRows) == 0 { + gprint.PrintWarning("no installed sdk found!") + return + } + + for _, r := range installedRows { + gprint.PrintInfo(r[0]) + } +} + func (v *SDKSearcher) RegisterKeyEvents(ll *table.List) { // Open homepage. ll.SetKeyEventForTable("o", table.KeyEvent{