flags

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: Apache-2.0

Copyright © 2023 The listen.dev team <engineering@garnet.ai>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright © 2023 The listen.dev team <engineering@garnet.ai>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright © 2023 The listen.dev team <engineering@garnet.ai>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright © 2023 The listen.dev team <engineering@garnet.ai>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var EnvPrefix = "lstn"

EnvPrefix is the prefix of the env variables corresponding to the global flags.

View Source
var EnvSeparator = "_"

EnvSeparator is the separator between the env variable prefix and the global flag name.

Functions

func Define added in v0.1.0

func Define(c *cobra.Command, o interface{}, startingGroup string)

func GetDefaults added in v0.1.0

func GetDefaults(o interface{}) map[string]string

func GetField added in v0.1.0

func GetField(o interface{}, name string) reflect.Value

func GetNames added in v0.1.0

func GetNames(o interface{}) map[string]string

func Transform added in v0.1.0

func Transform(ctx context.Context, o interface{}) error

func Validate added in v0.1.0

func Validate(o interface{}) []error

Types

type ConfigFlags added in v0.1.0

type ConfigFlags struct {
	LogLevel string `default:"info" name:"log level" flag:"loglevel" desc:"set the logging level"`                           // TODO > validator
	Timeout  int    `default:"60" name:"timeout" flag:"timeout" desc:"set the timeout, in seconds" validate:"number,min=30"` // FIXME: change to time.Duration type
	Endpoint string ``                                                                                                       /* 163-byte string literal not displayed */
}

func NewConfigFlags added in v0.1.0

func NewConfigFlags() (*ConfigFlags, error)

func (*ConfigFlags) Transform added in v0.1.0

func (o *ConfigFlags) Transform(ctx context.Context) error

func (*ConfigFlags) Validate added in v0.1.0

func (o *ConfigFlags) Validate() []error

type JSONFlags

type JSONFlags struct {
	JSON bool   `name:"json" flag:"json" desc:"output the verdicts (if any) in JSON form"`
	JQ   string `name:"jq" flag:"jq" shorthand:"q" desc:"filter the output using a jq expression" validate:"excluded_without=JSON,jq"`
}

func (*JSONFlags) GetOutput

func (o *JSONFlags) GetOutput(ctx context.Context, input io.Reader, output io.Writer) error

func (*JSONFlags) GetQuery

func (o *JSONFlags) GetQuery() string

func (*JSONFlags) IsJSON

func (o *JSONFlags) IsJSON() bool

type RegistryFlags added in v0.3.0

type RegistryFlags struct {
	URL string `` /* 144-byte string literal not displayed */
}

func (*RegistryFlags) Transform added in v0.3.0

func (o *RegistryFlags) Transform(ctx context.Context) error

func (*RegistryFlags) Validate added in v0.3.0

func (o *RegistryFlags) Validate() []error

Jump to

Keyboard shortcuts

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