summaryrefslogtreecommitdiffstats
path: root/cmd/root.go
blob: c4239ba31439d50a735af833f7c4d0fdd5e03828 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package cmd

import (
	"fmt"
	"os"

	"git.db.org.ai/dborg/internal/utils"
	"github.com/spf13/cobra"
)

var (
	jsonOutput bool
)

var rootCmd = &cobra.Command{
	Use:   "dborg",
	Short: "DB.org.ai CLI client",
	Long: `█▀▀▄ █▀▀▄   █▀▀█ █▀▀█ █▀▀▀   █▀▀█ ▀█▀
█░░█░█▀▀▄░░░█░░█░█▄▄▀░█░▀█░░░█▄▄█░░█
▀▀▀▀ ▀▀▀▀ ▀ ▀▀▀▀ ▀  ▀ ▀▀▀▀ ▀ ▀  ▀ ▀▀▀
DB.org.ai CLI client`,
	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
		return utils.CheckForUpdates(cmd)
	},
}

func Execute() {
	if err := rootCmd.Execute(); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
}

func init() {
	rootCmd.PersistentFlags().BoolVarP(&jsonOutput, "json", "j", false, "Output raw JSON instead of formatted text")
}

func IsJSONOutput() bool {
	return jsonOutput
}