flags

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: Apache-2.0 Imports: 9 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.

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 GetConfigFlagsDefaults

func GetConfigFlagsDefaults() map[string]string

func GetConfigFlagsNames

func GetConfigFlagsNames() map[string]string

Types

type ConfigOptions

type ConfigOptions struct {
	LogLevel string `default:"info" name:"log level" flag:"loglevel"` // TODO > validator
	Timeout  int    `default:"60" name:"timeout" flag:"timeout" validate:"number,min=30"`
	Endpoint string `default:"https://npm.listen.dev" flag:"endpoint" name:"endpoint" validate:"url,endpoint" transform:"tsuffix=/"`
	// contains filtered or unexported fields
}

func NewConfigOptions

func NewConfigOptions() (*ConfigOptions, error)

func (*ConfigOptions) GetField

func (o *ConfigOptions) GetField(name string) reflect.Value

func (*ConfigOptions) Transform

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

func (*ConfigOptions) Validate

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

type InOptions

type InOptions struct {
	JSONFlags
	// contains filtered or unexported fields
}

func NewInOptions

func NewInOptions() (*InOptions, error)

func (*InOptions) Attach

func (o *InOptions) Attach(c *cobra.Command)

func (*InOptions) Transform

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

func (*InOptions) Validate

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

type JSONFlags

type JSONFlags struct {
	JSON bool   `name:"json"`
	JQ   string `name:"jq" validate:"excluded_without=JSON,jq"`
}

func (*JSONFlags) Attach

func (o *JSONFlags) Attach(c *cobra.Command)

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 Options

type Options interface {
	Validate() []error
	Transform(context.Context) error
}

type ToOptions

type ToOptions struct {
	JSONFlags
	// contains filtered or unexported fields
}

func NewToOptions

func NewToOptions() (*ToOptions, error)

func (*ToOptions) Attach

func (o *ToOptions) Attach(c *cobra.Command)

func (*ToOptions) Transform

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

func (*ToOptions) Validate

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

Jump to

Keyboard shortcuts

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