version

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:     "version",
	Aliases: typex.StrOf("v"),
	Short:   "Print the dependency package information",
	Example: trim(`
lug version
lug version json
lug version t`),
	Run: func(cmd *cobra.Command, args []string) {
		defer xerror.RespExit()

		info, ok := debug.ReadBuildInfo()
		if !ok {
			return
		}

		var typ string

		if len(args) > 0 {
			typ = args[0]
		}

		switch typ {
		case "":
			dt, err := json.MarshalIndent(version.GetVer(), "", "\t")
			xerror.Panic(err)
			fmt.Println(string(dt))
		case "json":
			dt, err := json.MarshalIndent(info, "", "\t")
			xerror.Panic(err)
			fmt.Println(string(dt))
		case "table", "tb", "t":
			table := tablewriter.NewWriter(os.Stdout)
			table.SetHeader([]string{"path", "Version", "Replace"})
			table.Append([]string{info.Main.Path, version.Version, replace(info.Main.Replace)})

			for _, dep := range info.Deps {
				table.Append([]string{dep.Path, dep.Version, replace(dep.Replace)})
			}
			table.Render()
		}
	},
}

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