datum

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package datum is our cobra/viper cli implementation

Index

Constants

This section is empty.

Variables

View Source
var (
	// RootHost contains the root url for the Datum API
	RootHost string
	// GraphAPIHost contains the url for the Datum graph api
	GraphAPIHost string
)
View Source
var (
	Logger *zap.SugaredLogger
)
View Source
var RootCmd = &cobra.Command{
	Use:   appName,
	Short: fmt.Sprintf("a %s cli", appName),
}

RootCmd represents the base command when called without any subcommands

Functions

func Execute

func Execute()

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 GetFields

func GetFields(i interface{}) (res []string)

GetFields returns the value of each field in a struct

func GetHeaders

func GetHeaders(s interface{}, prefix string) []string

GetHeaders returns the name of each field in a struct

func JSONPrint

func JSONPrint(s []byte) error

func RowsTablePrint

func RowsTablePrint(resp GraphResponse) error

RowsTablePrint prints a table to the console with multiple rows using a map[string]interface{} as the row data

func SingleRowTablePrint

func SingleRowTablePrint(r interface{}) error

SingleRowTablePrint prints a single row table to the console

func TablePrint

func TablePrint(header []string, data [][]string) error

TablePrint prints a table to the console

func ViperBindFlag

func ViperBindFlag(name string, flag *pflag.Flag)

ViperBindFlag provides a wrapper around the viper bindings that panics if an error occurs

Types

type CLI

type CLI struct {
	Client      geodeticclient.GeodeticClient
	Interceptor clientv2.RequestInterceptor
	AccessToken string
}

func GetGraphClient

func GetGraphClient() (*CLI, error)

type Edge

type Edge struct {
	Node interface{} `json:"node"`
}

Edge is a single edge in the graph response

type GraphResponse

type GraphResponse struct {
	Edges []Edge `json:"edges"`
}

GraphResponse is the response from the graph api containing a list of edges

type RequiredFieldMissingError

type RequiredFieldMissingError struct {
	// Field contains the required field that was missing from the input
	Field string
}

RequiredFieldMissingError is returned when a field is required but not provided

func NewRequiredFieldMissingError

func NewRequiredFieldMissingError(f string) *RequiredFieldMissingError

NewRequiredFieldMissingError returns an error for a missing required field

func (*RequiredFieldMissingError) Error

func (e *RequiredFieldMissingError) Error() string

Error returns the RequiredFieldMissingError in string format

Directories

Path Synopsis
Package geodeticdatabase is our cobra/viper cli for database endpoints
Package geodeticdatabase is our cobra/viper cli for database endpoints
Package geodeticgroup is our cobra/viper cli for group endpoints
Package geodeticgroup is our cobra/viper cli for group endpoints
Package version contains the version information for the CLI
Package version contains the version information for the CLI

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL