chore: nfctl version, check cmd
This commit is contained in:
16
nft/nfctl/cmd/check.go
Normal file
16
nft/nfctl/cmd/check.go
Normal file
@ -0,0 +1,16 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/loveuer/nf/nft/nfctl/version"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
checkCmd = &cobra.Command{
|
||||
Use: "check",
|
||||
Short: "nfctl new version check",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
version.Check(true, true, 30)
|
||||
},
|
||||
}
|
||||
)
|
@ -1,19 +1,30 @@
|
||||
package cmd
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
import (
|
||||
"github.com/loveuer/nf/nft/log"
|
||||
"github.com/loveuer/nf/nft/nfctl/opt"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
Root = &cobra.Command{
|
||||
Use: "nfctl",
|
||||
Short: "nfctl: easy start your nf backend work",
|
||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||
if opt.Debug == true {
|
||||
log.SetLogLevel(log.LogLevelDebug)
|
||||
}
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
initNew()
|
||||
Root.PersistentFlags().BoolVar(&opt.Debug, "debug", false, "debug mode")
|
||||
|
||||
Root.AddCommand(
|
||||
versionCmd,
|
||||
checkCmd,
|
||||
cmdNew,
|
||||
)
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"github.com/loveuer/nf/nft/nfctl/clone"
|
||||
"github.com/loveuer/nf/nft/nfctl/opt"
|
||||
"github.com/loveuer/nf/nft/nfctl/tp"
|
||||
"github.com/loveuer/nf/nft/nfctl/version"
|
||||
"github.com/spf13/cobra"
|
||||
"net/url"
|
||||
"os"
|
||||
@ -33,14 +34,11 @@ nfctl new {project} --template http://username:token@my.gitlab.com/my-zone/my-re
|
||||
)
|
||||
|
||||
func initNew() {
|
||||
cmdNew.Flags().BoolVar(&opt.Debug, "debug", false, "debug mode")
|
||||
cmdNew.Flags().StringVarP(&template, "template", "t", "", "template name/url[example:ultone, https://github.com/xxx/yyy.git]")
|
||||
cmdNew.Flags().BoolVar(&disableInit, "without-init", false, "don't run template init script")
|
||||
|
||||
cmdNew.RunE = func(cmd *cobra.Command, args []string) error {
|
||||
if opt.Debug {
|
||||
log.SetLogLevel(log.LogLevelDebug)
|
||||
}
|
||||
version.Check(true, false, 5)
|
||||
|
||||
var (
|
||||
err error
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/loveuer/nf/nft/log"
|
||||
"github.com/fatih/color"
|
||||
"github.com/loveuer/nf/nft/nfctl/version"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@ -11,7 +11,8 @@ var (
|
||||
Use: "version",
|
||||
Short: "print nfctl version and exit",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
log.Info("version: %s", version.Version)
|
||||
color.Cyan("nfctl - version: %s", version.Version)
|
||||
version.Check(true, false, 5)
|
||||
},
|
||||
}
|
||||
)
|
||||
|
Reference in New Issue
Block a user