Esempio n. 1
0
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) > 1 {
			P(WARING, "use parameter maximum is 1, temporary only support <%v>, <%v>, please check your input. See '%v'.\n", "global", "latest", "gnvm help node-version")
		} else if len(args) == 1 {

			args[0] = util.EqualAbs("global", args[0])
			args[0] = util.EqualAbs("latest", args[0])

			switch {
			case args[0] != "global" && args[0] != "latest":
				P(WARING, "gnvm node-version only support <%v>, <%v> parameter.\n", "global", "latest")
			case args[0] != "latest" && remote:
				P(WARING, "gnvm node-version only support <%v> parameter.\n", "latest --remote")
			}
		}
		nodehandle.NodeVersion(args, remote)
	},
}

// sub cmd
var configCmd = &cobra.Command{
	Use:   "config",
	Short: "Setter and getter registry",
	Long: `Setter and getter registry e.g.
gnvm config registry
gnvm config registry http://dist.u.qiniudn.com/
gnvm config registry DEFAULT
gnvm config INIT`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 1 {
Esempio n. 2
0
gnvm node-version latest     :Show Node.js latest version, and fix it.
gnvm node-version global     :Show Node.js global version, and fix it.
`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) > 1 {
			P(WARING, "%v parameter only support [%v] or [%v] keyword, please check your input. See '%v'.\n", "gnvm node-version", "global", "latest", "gnvm help node-version")
		} else {
			if len(args) == 1 {
				args[0] = util.EqualAbs("global", args[0])
				args[0] = util.EqualAbs("latest", args[0])
				if args[0] != "global" && args[0] != "latest" {
					P(WARING, "%v parameter only support [%v] or [%v] keyword, please check your input. See '%v'.\n", "gnvm node-version", "global", "latest", "gnvm help node-version")
					return
				}
			}
			nodehandle.NodeVersion(args)
		}
	},
}

// sub cmd
var configCmd = &cobra.Command{
	Use:   "config",
	Short: "Setter and getter .gnvmrc file",
	Long: `Setter and getter .gnvmrc file.  e.g. :
gnvm config                   :Print all propertys from .gnvmrc.
gnvm config INIT              :Initialization .gnvmrc file.
gnvm config [props]           :Get .gnvmrc file props.
gnvm config registry [custom] :Custom  is valid url.
gnvm config registry DEFAULT  :DEFAULT is built-in variable. value is http://nodejs.org/dist/
gnvm config registry TAOBAO   :TAOBAO  is built-in variable. value is http://npm.taobao.org/mirrors/node