summaryrefslogtreecommitdiffstats
path: root/cmd/helpers.go
blob: 133fb0a69c15641880add88bee2c49da5e97364e (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
package cmd

import (
	"fmt"

	"git.db.org.ai/dborg/internal/client"
	"git.db.org.ai/dborg/internal/config"
)

func newClient() (*client.Client, error) {
	return client.New(config.New().WithDebug(debugOutput))
}

func newUnauthenticatedClient() (*client.Client, error) {
	return client.NewUnauthenticated(config.New().WithDebug(debugOutput))
}

func checkError(errorMsg string) error {
	if errorMsg != "" {
		return fmt.Errorf("API error: %s", errorMsg)
	}
	return nil
}

func printOutput(output string) {
	fmt.Print(output)
}