java

package
v0.0.0-...-436813c Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const Header = `#!/bin/sh`
View Source
const Tails = `` /* 421-byte string literal not displayed */

Variables

View Source
var AddCmd = &cobra.Command{
	Use:     "add",
	Aliases: []string{"a"},
	Short:   "Add alternative java version",
	Long:    `Add alternative java version`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			AskAndAdd()
		}
	},
}
View Source
var GenShCmd = &cobra.Command{
	Use:     "gen_sh",
	Aliases: []string{"gen"},
	Short:   "Generate shell script",
	Long:    `Generate shell script`,
	Run: func(cmd *cobra.Command, args []string) {
		var keys []define.Java
		row := JavaVersionDB.Find(&keys).RowsAffected
		if row == 0 {
			log.Error("Affect Rows is 0")
			return
		}
		log.Info("You have Java version: ")
		for _, v := range keys {
			log.Infof("- %v: %v @ %v", v.Version, v.DetailVersion, v.JavaHome)
		}
		log.Info("Generate shell script")
		shellFileContent := GenShCmds(keys)
		err := os.WriteFile(misc.Configlocate(), []byte(shellFileContent), 0644)
		if err != nil {
			log.Error(err)
		}
		log.Info("Generate shell script success")
		log.Info("ShellScript location at ", misc.Configlocate())
		log.Info("Please run following command to enable in your shell")
		log.Infof("echo 'source %v' >> ~/.zshrc", misc.Configlocate())
		log.Infof("echo 'source %v' >> ~/.bashrc", misc.Configlocate())
		log.Infof("switching your Java Version With command")
		log.Infof("use_java_<version>")
		log.Infof("example: use_java_8")
	},
}
View Source
var JavaVersionDB *gorm.DB

Functions

func AskAndAdd

func AskAndAdd() *define.Java

func GenShCmds

func GenShCmds(keys []define.Java) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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