52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
/*
|
|
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
|
|
|
*/
|
|
package cmd
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
var verbose = false
|
|
var acceptAll = false
|
|
|
|
// rootCmd represents the base command when called without any subcommands
|
|
var rootCmd = &cobra.Command{
|
|
Use: "boot",
|
|
Short: "Boot is a toolbox app to bootstrap quickly a Go-Swagger API",
|
|
Long: `Boot is a toolbox app to bootstrap quickly a Go-Swagger API.
|
|
|
|
It will:
|
|
- Auto-Update
|
|
- Download dependencies (go-swagger, ...)
|
|
- Initialize an API with default middlewares
|
|
- Generate Models / Controlers
|
|
- Generate Database structs
|
|
- ....`,
|
|
|
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
|
if verbose {
|
|
log.SetLevel(log.DebugLevel)
|
|
}
|
|
},
|
|
}
|
|
|
|
// Execute adds all child commands to the root command and sets flags appropriately.
|
|
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
|
func Execute() {
|
|
err := rootCmd.Execute()
|
|
if err != nil {
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "enable verbose logging")
|
|
rootCmd.PersistentFlags().BoolVarP(&acceptAll, "yes", "y", false, "accept all change, disable interactive process")
|
|
}
|