flags

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: Apache-2.0 Imports: 21 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 EnvReplacer = strings.NewReplacer("-", EnvSeparator, ".", EnvSeparator)

EnvReplacer is the string replacer that defines the transformation for flag names into environment variable names.

View Source
var EnvSeparator = "_"

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

Functions

func AsJSON added in v0.4.0

func AsJSON(o interface{}) string

func Define added in v0.1.0

func Define(c *cobra.Command, o interface{}, startingGroup string, exclusions []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 GetFieldTag added in v0.13.0

func GetFieldTag(o interface{}, name string) (reflect.StructTag, bool)

func GetNames added in v0.1.0

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

func GetTypes added in v0.4.0

func GetTypes(o interface{}) map[string]reflect.Type

func Transform added in v0.1.0

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

func Translate added in v0.13.0

func Translate(err error, prefix string) []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"  desc:"set the logging level"       flag:"loglevel" flagset:"Config" json:"loglevel" name:"log level"` // TODO > validator
	Timeout  int    ``                                                                                                                     // FIXME: change to time.Duration type
	/* 141-byte string literal not displayed */
	Endpoint Endpoint `json:"endpoint"`
	Token
	Registry
	Reporting
	Filtering
	Lockfiles []string `` /* 199-byte string literal not displayed */
}

ConfigFlags are the options that the CLI also reads from the YAML configuration file.

func NewConfigFlags added in v0.1.0

func NewConfigFlags() (*ConfigFlags, error)

func (*ConfigFlags) Define added in v0.4.0

func (o *ConfigFlags) Define(c *cobra.Command, exclusions []string)

func (*ConfigFlags) SetDefaults added in v0.5.0

func (o *ConfigFlags) SetDefaults()

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 DebugFlags added in v0.4.0

type DebugFlags struct {
	DebugOptions bool `desc:"output the options, then exit" flag:"debug-options" json:"debug-options" name:"debug options"`
}

type Endpoint added in v0.12.0

type Endpoint struct {
	Npm  string `` /* 208-byte string literal not displayed */
	PyPi string `` /* 208-byte string literal not displayed */
	Core string `` /* 199-byte string literal not displayed */
}

func (Endpoint) IsLocalCore added in v0.17.0

func (e Endpoint) IsLocalCore() bool

IsLocalCore returns true if the Core API endpoint is a local one. It is considered local and endpoint with fixed IP address and http scheme.

type Filtering added in v0.6.0

type Filtering struct {
	Ignore     `flagset:"Filtering"`
	Expression string `` /* 167-byte string literal not displayed */
}

type GitHub added in v0.4.0

type GitHub struct {
	Owner string `desc:"set the GitHub owner name (org|user)" flag:"gh-owner" flagset:"Reporting" json:"gh-owner" name:"github owner"`
	Repo  string `desc:"set the GitHub repository name"       flag:"gh-repo"  flagset:"Reporting" json:"gh-repo"  name:"github repository"`
	Pull
}

type Ignore added in v0.6.0

type Ignore struct {
	Packages []string          `` /* 191-byte string literal not displayed */
	Deptypes []npmdeptype.Enum `` /* 168-byte string literal not displayed */
	// contains filtered or unexported fields
}

type JSONFlags

type JSONFlags struct {
	JSON bool   `desc:"output the verdicts (if any) in JSON form"                          flag:"json" json:"json"         name:"json"`
	JQ   string `` /* 177-byte string literal not displayed */
}

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 Pull added in v0.4.0

type Pull struct {
	ID int `desc:"set the GitHub pull request ID" flag:"gh-pull-id" flagset:"Reporting" json:"gh-pull-id" name:"github pull request ID"`
}

type Registry added in v0.4.0

type Registry struct {
	NPM string `` /* 195-byte string literal not displayed */
}

type Reporting added in v0.6.0

type Reporting struct {
	Types []cmd.ReportType `desc:"set one or more reporters to use" flag:"reporter" flagset:"Reporting" json:"reporter" shorthand:"r" transform:"unique"`
	GitHub
	// contains filtered or unexported fields
}

NOTE > Struct can't have the same name of a flag.

type Token added in v0.4.0

type Token struct {
	GitHub string `` /* 136-byte string literal not displayed */
	JWT    string `` /* 136-byte string literal not displayed */
}

type TokenMandatory added in v0.16.0

type TokenMandatory struct {
	GitHub string `` /* 127-byte string literal not displayed */
	JWT    string `` /* 127-byte string literal not displayed */
}

Jump to

Keyboard shortcuts

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