cmd

package
v1.0.22 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const RecordFileName = ".gocmd"

Variables

View Source
var (
	RootCmd = &cobra.Command{
		Use: "gocmd",
	}

	InitCmd = &cobra.Command{
		Use:   "init",
		Short: "Save all golang cli",
		PreRun: func(cmd *cobra.Command, args []string) {
			if srcPath == "" {
				srcPath = getSrcPathFromEnv()
			}

			if binPath == "" {
				binPath = getBinPathFromEnv()
			}

			if dotGoCmdDir == "" {
				var err error
				dotGoCmdDir, err = homedir.Dir()

				if err != nil {
					panic(err)
				}
			}

			if errors := existsDir(srcPath, binPath, dotGoCmdDir); len(errors) > 0 {
				for _, err := range errors {
					color.Red(err.Error())
				}
				os.Exit(1)
			}
		},
		Run: func(cmd *cobra.Command, args []string) {
			gitDirs := goCommands(srcPath, binPath)
			recordFile(gitDirs, dotGoCmdDir)
			color.Green("created \"%v\" successfully!", path.Join(dotGoCmdDir, RecordFileName))
		},
	}

	InstallCmd = &cobra.Command{
		Use:   "install",
		Short: "Install golang cli from .gocmd",
		PreRun: func(cmd *cobra.Command, args []string) {
			if dotGoCmdDir == "" {
				var err error
				dotGoCmdDir, err = homedir.Dir()

				if err != nil {
					panic(err)
				}
			}

			if errors := existsDir(dotGoCmdDir); len(errors) > 0 {
				for _, err := range errors {
					color.Red(err.Error())
				}
				os.Exit(1)
			}
		},
		Run: func(cmd *cobra.Command, args []string) {
			install(dotGoCmdDir)
		},
	}
)

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