cmd

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GitPullMulti = &gcli.Command{
	Name:    "git:pull",
	UseFor:  "use git pull for update multi project",
	Aliases: []string{"git-pull"},
	Config: func(c *gcli.Command) {
		c.AddArg(
			"basePath",
			"the base operate dir path. default is current dir",
			true,
		).WithValidator(func(v interface{}) (i interface{}, e error) {
			if !fsutil.IsDir(v.(string)) {
				return nil, fmt.Errorf("the base path must be an exist dir")
			}
			return v, nil
		})

		c.AddArg(
			"dirNames",
			"the operate dir names in the base path, allow multi by spaces",
			false, true,
		)
	},
	Examples: `
	{$fullCmd} /my/workspace project1 project2
`,
	Func: func(c *gcli.Command, _ []string) (err error) {
		var ret string
		basePath := c.Arg("basePath").String("./")
		dirNames := c.Arg("dirNames").Strings()

		if len(dirNames) == 0 {
			dirNames = getSubDirs(basePath)
			if len(dirNames) == 0 {
				return fmt.Errorf("no valid subdirs in the base path: %s", basePath)
			}
		}

		color.Green.Println("The operate bash path:", basePath)
		fmt.Println("- want updated project dir names:", dirNames)

		for _, name := range dirNames {
			ret, err = execCmd("git pull", path.Join(basePath, name))
			if err != nil {
				return
			}
			color.Info.Println("RESULT:")
			fmt.Println(ret)
		}

		color.Cyan.Println("Update Complete :)")
		return
	},
}

GitPullMulti use git pull for update multi project

Functions

func ColorCommand

func ColorCommand() *gcli.Command

ColorCommand command definition

func DaemonRunCommand

func DaemonRunCommand() *gcli.Command

func EmojiDemoCmd

func EmojiDemoCmd() *gcli.Command

func EnvInfoCommand

func EnvInfoCommand() *gcli.Command

EnvInfoCommand

func ExampleCommand

func ExampleCommand() *gcli.Command

ExampleCommand command definition

func GitCommand

func GitCommand() *gcli.Command

GitCommand

func InteractDemoCommand

func InteractDemoCommand() *gcli.Command

InteractDemoCommand create

func ProgressDemoCmd

func ProgressDemoCmd() *gcli.Command

func ShowDemoCommand

func ShowDemoCommand() *gcli.Command

ShowDemoCommand create

func SpinnerDemoCmd

func SpinnerDemoCmd() *gcli.Command

Types

type GitInfoData

type GitInfoData struct {
	Tag       string `json:"tag" description:"get tag name"`
	Version   string `json:"version" description:"git repo version."`
	ReleaseAt string `json:"releaseAt" description:"latest commit date"`
}

type Names

type Names []string

The string flag list, implemented flag.Value interface

func (*Names) Set

func (ns *Names) Set(value string) error

func (*Names) String

func (ns *Names) String() string

Jump to

Keyboard shortcuts

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