github.com/unionj-cloud/go-doudou@v1.3.8-0.20221011095552-0088008e5b31/cmd/run.go (about)

     1  package cmd
     2  
     3  import (
     4  	"github.com/unionj-cloud/go-doudou/cmd/internal/svc"
     5  
     6  	"github.com/spf13/cobra"
     7  )
     8  
     9  var watch bool
    10  
    11  var RunSvc = svc.NewSvc
    12  
    13  // runCmd runs the service
    14  var runCmd = &cobra.Command{
    15  	Use:   "run",
    16  	Short: "run go-doudou program",
    17  	Long:  ``,
    18  	Run: func(cmd *cobra.Command, args []string) {
    19  		s := RunSvc("")
    20  		s.Run(watch)
    21  	},
    22  }
    23  
    24  func init() {
    25  	svcCmd.AddCommand(runCmd)
    26  
    27  	// Here you will define your flags and configuration settings.
    28  
    29  	// Cobra supports Persistent Flags which will work for this command
    30  	// and all subcommands, e.g.:
    31  	// runCmd.PersistentFlags().String("foo", "", "A help for foo")
    32  
    33  	// Cobra supports local flags which will only run when this command
    34  	// is called directly, e.g.:
    35  	runCmd.Flags().BoolVarP(&watch, "watch", "w", false, "enable watch mode")
    36  }