mirror of
https://github.com/foomo/squadron.git
synced 2025-10-16 12:35:42 +00:00
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package actions
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/foomo/configurd"
|
|
"github.com/sirupsen/logrus"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var (
|
|
log = logrus.New()
|
|
cnf configurd.Configurd
|
|
rootCmd = &cobra.Command{
|
|
Use: "cobra",
|
|
Short: "A generator for Cobra based Applications",
|
|
Long: `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.`,
|
|
}
|
|
|
|
FlagTag string
|
|
FlagDir string
|
|
FlagVerbose bool
|
|
FlagNamespace string
|
|
// FlagGroup string
|
|
)
|
|
|
|
func init() {
|
|
baseDir, err := os.Getwd()
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
rootCmd.PersistentFlags().StringVarP(&FlagTag, "tag", "t", "latest", "Specifies the image tag")
|
|
rootCmd.PersistentFlags().StringVarP(&FlagDir, "dir", "d", baseDir, "Specifies working directory")
|
|
rootCmd.PersistentFlags().BoolVarP(&FlagVerbose, "verbose", "v", false, "Specifies should command output be displayed")
|
|
}
|
|
|
|
func Execute() {
|
|
var err error
|
|
cnf, err = configurd.New(log, FlagDir)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
if err := rootCmd.Execute(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|