vcli

package
v0.7.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GroupID string = "vmr"
)

Variables

View Source
var SearchVersionsCmd = &cobra.Command{
	Use:     "search",
	Aliases: []string{"s"},
	GroupID: GroupID,
	Short:   "Searches available versions.",
	Long:    "Example: vmr search <sdk-name>.",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Help()
			return
		}
		sdkName := args[0]
		l := cliui.NewVersionSearcher()
		if ok, _ := cmd.Flags().GetBool("search-by-conda"); ok {
			l.EnableCondaSearch()
		}
		l.Search(sdkName, "")
	},
}

search versions for an SDK

View Source
var SetupAutoCompletions = &cobra.Command{
	Use:     "add-completions",
	Aliases: []string{"ac"},
	GroupID: GroupID,
	Short:   "Add auto-completions for vmr to current shell profile.",
	Long:    "Example: vmr ac.",
	Run: func(cmd *cobra.Command, args []string) {
		completions.AddCompletionScriptToShellProfile()
	},
}
View Source
var ShowInstalledCmd = &cobra.Command{
	Use:     "local",
	Aliases: []string{"l"},
	GroupID: GroupID,
	Short:   "Shows installed versions for an SDK.",
	Long:    "Example: vmr local <sdk name>.",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Help()
			return
		}
		sdkName := args[0]
		l := cliui.NewLocalInstalled()
		l.Search(sdkName)
		l.Show()
	},
}

Show installed versions for an SDK.

View Source
var ShowInstalledSDKInfo = &cobra.Command{
	Use:     "installed-info",
	Aliases: []string{"ii"},
	GroupID: GroupID,
	Short:   "Shows installed SDK information.",
	Long:    "Example: vmr ii.",
	Run: func(cmd *cobra.Command, args []string) {
		l := cliui.NewSDKSearcher()
		installedSDKList := l.GetInstalledSDKList()
		for _, sdkName := range installedSDKList {
			ll := cliui.NewLocalInstalled()
			ll.Search(sdkName)
			versionListString := gprint.YellowStr("%s", sdkName) + ": " + gprint.CyanStr("%s", strings.Join(ll.VersionList, ", "))
			fmt.Println(versionListString)
		}
	},
}
View Source
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()
	},
}
View Source
var ShowSDKCmd = &cobra.Command{
	Use:     "show",
	Aliases: []string{"S"},
	GroupID: GroupID,
	Short:   "Show available SDKs.",
	Long:    "Show the SDKs supported by VMR.",
	Run: func(cmd *cobra.Command, args []string) {
		l := cliui.NewSDKSearcher()
		l.Show()
	},
}

show SDK list

View Source
var UninstallVersionCmd = &cobra.Command{
	Use:     "uninstall",
	Aliases: []string{"uni", "r"},
	GroupID: GroupID,
	Short:   "Uninstall versions for an SDK.",
	Long:    "Example: vmr uninstall sdkname@version or sdkname@all.",
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Help()
			return
		}
		versionInfo := args[0]
		if !strings.Contains(versionInfo, "@") {
			cmd.Help()
			return
		}
		sList := strings.Split(versionInfo, "@")
		if len(sList) != 2 || sList[1] == "" {
			cmd.Help()
			return
		}
		sdkName := sList[0]
		version := sList[1]

		if version == "all" {
			lif := installer.NewIVFinder(sdkName)
			lif.UninstallAllVersions()
		} else {
			versionFilePath := download.GetVersionFilePath(sdkName)
			content, _ := os.ReadFile(versionFilePath)
			rawVersionList := make(download.VersionList)
			json.Unmarshal(content, &rawVersionList)
			installerType := "unarchiver"
			for _, vl := range rawVersionList {
				if len(vl) > 0 {
					installerType = vl[0].Installer
					break
				}
			}
			ins := installer.NewInstaller(sdkName, version, "", download.Item{Installer: installerType})
			ins.Uninstall()
		}
	},
}

Uninstalls a version for an SDK.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL