cli

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var App *gcli.App

App instance

View Source
var InfoCmd = &gcli.Command{
	Name:    "info",
	Desc:    "display some information",
	Aliases: []string{"show"},
	Config: func(c *gcli.Command) {
		c.BoolOpt(&infoOpts.All, "all", "a", false, "display all loaded config data")
		c.BoolOpt(&infoOpts.Init, "init", "ri", false, "re-init goenv config to user config dir")
	},
	Func: func(c *gcli.Command, args []string) error {
		if infoOpts.Init {
			_, err := goenv.InitConfigFile(true)
			return err
		}

		color.Cyanln(strutil.Repeat(" ", 15), "Goenv Information")
		color.Cyanln(strutil.Repeat("=", 45))
		info, err := sysutil.OsGoInfo()
		if err != nil {
			return err
		}

		show.AList("GO Info", info)
		show.AList("App Config", goenv.Cfg)

		if infoOpts.All {
			color.Infop("\nAll Config: ")
			dump.NoLoc(goenv.CfgMgr.Data())
		}
		return nil
	},
}

InfoCmd define

View Source
var InstallCmd = &gcli.Command{
	Name:    "install",
	Desc:    "install new Go version",
	Aliases: []string{"i", "ins"},
	Config: func(c *gcli.Command) {
		c.StrOpt(&insOpts.dlHost, "dl-host", "dl", "", "custom download host, default use config")

		c.AddArg("version", "want installed go version", true)
	},
	Func: func(c *gcli.Command, args []string) error {
		ver := c.Arg("version").String()
		ver, err := checkFormatVersion(ver)
		if err != nil {
			return err
		}

		adaptor, err := makeAdaptor()
		if err != nil {
			return err
		}

		return adaptor.Install(ver)
	},
}

InstallCmd define

View Source
var ListCmd = &gcli.Command{
	Name:    "list",
	Desc:    "list installed Go version",
	Aliases: []string{"ls"},
	Config: func(c *gcli.Command) {

	},
	Func: func(c *gcli.Command, args []string) error {
		adaptor, err := makeAdaptor()
		if err != nil {
			return err
		}

		return adaptor.List()
	},
}

ListCmd define

View Source
var ShellCmd = &gcli.Command{
	Name: "shell",
	Desc: "generate shell script codes",
	Help: `
${binWithCmd} shell
`,
	Aliases: []string{"script"},
	Config: func(c *gcli.Command) {

	},
	Func: func(c *gcli.Command, args []string) error {
		return nil
	},
}

ShellCmd define

View Source
var SwitchCmd = &gcli.Command{
	Name:     "switch",
	Desc:     "switch Go to input version",
	Examples: `${binWithCmd} 1.16`,
	Aliases:  []string{"use"},
	Config: func(c *gcli.Command) {
		c.BoolOpt(&switchOpts.yes, "yes", "y", false, "set confirm default value")

		c.AddArg("version", "the target go version for switch", true)
	},
	Func: func(c *gcli.Command, args []string) error {
		ver := c.Arg("version").String()
		ver, err := checkFormatVersion(ver)
		if err != nil {
			return err
		}

		adaptor, err := makeAdaptor()
		if err != nil {
			return err
		}

		adaptor.ApplyOpFunc(func(opts *internal.CallOpts) {
			opts.Yes = switchOpts.yes
		})
		return adaptor.Switch(ver)
	},
}

SwitchCmd define

View Source
var UninstallCmd = &gcli.Command{
	Name:    "uninstall",
	Desc:    "uninstall input Go version",
	Aliases: []string{"un", "uni", "rm"},
	Config: func(c *gcli.Command) {
		c.AddArg("version", "want uninstalled go version", true)
	},
	Func: func(c *gcli.Command, args []string) error {
		ver := c.Arg("version").String()
		ver, err := checkFormatVersion(ver)
		if err != nil {
			return err
		}

		adaptor, err := makeAdaptor()
		if err != nil {
			return err
		}

		return adaptor.Uninstall(ver)
	},
}

UninstallCmd define

View Source
var UpdateCmd = &gcli.Command{
	Name:    "update",
	Desc:    "update input Go version",
	Aliases: []string{"u", "up"},
	Config: func(c *gcli.Command) {
		c.StrOpt(&upOpts.dlHost, "dl-host", "dl", "", "custom download host, default use config")

		c.AddArg("version", "want updated go version", true)
	},
	Func: func(c *gcli.Command, args []string) error {
		ver := c.Arg("version").String()
		ver, err := checkFormatVersion(ver)
		if err != nil {
			return err
		}

		adaptor, err := makeAdaptor()
		if err != nil {
			return err
		}

		return adaptor.Update(ver)
	},
}

UpdateCmd define

Functions

func Run

func Run()

Run cli app

Types

This section is empty.

Jump to

Keyboard shortcuts

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