github.com/youminxue/odin@v0.0.0-20230216022911-c2c8b05d3a41/cmd/root.go (about)

     1  package cmd
     2  
     3  import (
     4  	"github.com/sirupsen/logrus"
     5  	"github.com/spf13/cobra"
     6  	"github.com/youminxue/odin/cmd/internal/svc/codegen"
     7  	"github.com/youminxue/odin/version"
     8  )
     9  
    10  // rootCmd is the base command when called without any subcommands
    11  var rootCmd = &cobra.Command{
    12  	Version: version.Release,
    13  	Use:     "odin",
    14  	Short:   "odin is microservice rapid develop framework based on openapi 3.0 spec and gossip protocol",
    15  	Long: `odin works like a scaffolding tool but more than that. 
    16  it lets api providers design their apis and help them code less. 
    17  it generates openapi 3.0 spec json document for frontend developers or other api consumers to understand what apis there, 
    18  consumers can import it into postman to debug and test, or upload it into some code generators to download client sdk.
    19  it provides some useful components and middleware for constructing microservice cluster like service register and discovering, 
    20  load balancing and so on. it just begins, more features will come out soon.`,
    21  	Run: func(cmd *cobra.Command, args []string) {
    22  	},
    23  }
    24  
    25  // Execute adds all child commands to the root command and sets flags appropriately.
    26  // This is called by main.main(). It only needs to happen once to the rootCmd.
    27  func Execute() {
    28  	codegen.ParseDto("/Users/hetao/code/golang/src/git.corp.hetao101.com/backend/test1/", "dto")
    29  	cobra.CheckErr(rootCmd.Execute())
    30  }
    31  
    32  func init() {
    33  	customFormatter := new(logrus.TextFormatter)
    34  	customFormatter.TimestampFormat = "2006-01-02 15:04:05"
    35  	customFormatter.FullTimestamp = true
    36  	logrus.SetFormatter(customFormatter)
    37  }
    38  
    39  func GetRootCmd() *cobra.Command {
    40  	return rootCmd
    41  }