mirror of
https://github.com/liloew/gvn.git
synced 2025-12-24 13:38:00 +08:00
modify command comment and fix windows down command
This commit is contained in:
19
cmd/down.go
19
cmd/down.go
@@ -25,16 +25,10 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// downCmd represents the down command
|
||||
var downCmd = &cobra.Command{
|
||||
Use: "down",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Short: "stop gvn",
|
||||
Long: `Stop gvn through the pid or pid file (default)`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
var pid int
|
||||
if p, err := cmd.Flags().GetUint32("pid"); err == nil && pid > 0 {
|
||||
@@ -50,7 +44,14 @@ to quickly create a Cobra application.`,
|
||||
logrus.WithFields(logrus.Fields{
|
||||
"PID": pid,
|
||||
}).Info("kill gvn process")
|
||||
syscall.Kill(pid, syscall.SIGINT)
|
||||
if p, err := os.FindProcess(pid); err == nil {
|
||||
p.Signal(syscall.SIGINT)
|
||||
} else {
|
||||
logrus.WithFields(logrus.Fields{
|
||||
"ERROR": err,
|
||||
"PID": pid,
|
||||
}).Error("Kill process error")
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -57,13 +57,8 @@ type Config struct {
|
||||
var (
|
||||
initCmd = &cobra.Command{
|
||||
Use: "init",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Short: "generate gvn config file",
|
||||
Long: `Generate the gvn.yaml file for server and clients`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if _, err := os.Stat(viper.ConfigFileUsed()); err == nil {
|
||||
if force, _ := cmd.Flags().GetBool("force"); !force {
|
||||
|
||||
17
cmd/root.go
17
cmd/root.go
@@ -27,16 +27,8 @@ import (
|
||||
var (
|
||||
rootCmd = &cobra.Command{
|
||||
Use: "gvn",
|
||||
Short: "A brief description of your application",
|
||||
Long: `A longer description that spans multiple lines and likely contains
|
||||
examples and usage of using your application. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
// Uncomment the following line if your bare application
|
||||
// has an action associated with it:
|
||||
// Run: func(cmd *cobra.Command, args []string) { },
|
||||
Short: "gvn - a golang implementation VPN aims on distributed work environments",
|
||||
Long: ``,
|
||||
}
|
||||
cfgFile string
|
||||
)
|
||||
@@ -79,10 +71,5 @@ func initConfig() {
|
||||
if err := viper.ReadInConfig(); err == nil {
|
||||
// PASS
|
||||
} else {
|
||||
// logrus.WithFields(logrus.Fields{
|
||||
// "File": viper.ConfigFileUsed(),
|
||||
// "KEYS": viper.AllKeys(),
|
||||
// "ERROR": err,
|
||||
// }).Error("Read config file error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,13 +44,8 @@ import (
|
||||
var (
|
||||
upCmd = &cobra.Command{
|
||||
Use: "up",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Short: "run gvn",
|
||||
Long: `Run gvn using the configure file (gvn.yaml)`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("up called")
|
||||
upCommand(cmd)
|
||||
|
||||
Reference in New Issue
Block a user