48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
package cmd
|
||
|
||
import (
|
||
"context"
|
||
"fmt"
|
||
"os"
|
||
|
||
"git.badhouseplants.net/allanger/giops/internal/build"
|
||
"github.com/spf13/cobra"
|
||
)
|
||
|
||
var fullVersion = fmt.Sprintf("%s - %s", build.Version, build.CommitHash)
|
||
var longDescription = `---
|
||
Giops is just GitOps with a glottal T
|
||
|
||
It's a tool that is supposed to help engineers follow the GitOps practies
|
||
without fighting with GitOps being inapplicable to the real world.
|
||
|
||
Yeah, I quite hate this GitOps obsession, but since it's already there,
|
||
I think it makes sense to make it work.
|
||
|
||
---
|
||
Information about the build:
|
||
Version: %s (build on %s)
|
||
|
||
---
|
||
`
|
||
|
||
var (
|
||
rootCmd = &cobra.Command{
|
||
Use: "giops",
|
||
Short: "giops – GitOps without pain, kinda",
|
||
Long: fmt.Sprintf(longDescription, fullVersion, build.BuildTime),
|
||
SilenceErrors: true,
|
||
SilenceUsage: true,
|
||
Version: build.Version,
|
||
}
|
||
)
|
||
|
||
func Execute(ctx context.Context) error {
|
||
rootCmd.PersistentFlags().Bool("server", false, "Set to true, if you want to start it in the deamon mode")
|
||
if err := rootCmd.ExecuteContext(ctx); err != nil {
|
||
fmt.Fprintf(os.Stderr, "Whoops. There was an error while executing your CLI '%s'", err)
|
||
os.Exit(1)
|
||
}
|
||
return nil
|
||
}
|