cli

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package cli is copied and adjusted code from: https://github.com/kubernetes-sigs/kind/blob/b6bc112522651d98c81823df56b7afa511459a3b/pkg/internal/env/term.go#L51

Index

Constants

View Source
const Name = "botkube"

Name represent the official CLI name

Variables

View Source
var ErrInvalidFormatType = fmt.Errorf("unknown verbose mode")

ErrInvalidFormatType is returned when an unsupported verbose mode is used.

View Source
var VerboseMode = VerboseModeDisabled

VerboseMode defines if CLI should use verbose mode

View Source
var VerboseModeHumanMapping = map[VerboseModeFlag]string{
	VerboseModeDisabled: "disable",
	VerboseModeSimple:   "simple",
	VerboseModeTracing:  "trace",
}

VerboseModeHumanMapping holds mapping between IDs and human-readable modes.

Functions

func IsSmartTerminal

func IsSmartTerminal(w io.Writer) bool

IsSmartTerminal returns true if the writer w is a terminal AND we think that the terminal is smart enough to use VT escape codes etc.

func RegisterVerboseModeFlag

func RegisterVerboseModeFlag(flags *pflag.FlagSet)

RegisterVerboseModeFlag registers VerboseMode flag.

Types

type Config added in v1.4.0

type Config struct {
	Token string `json:"token"`
}

Config is botkube cli config

func NewConfig added in v1.4.0

func NewConfig() (*Config, error)

NewConfig creates new Config from local data

func (*Config) Read added in v1.4.0

func (c *Config) Read() error

Read reads Config from local FS

func (*Config) Save added in v1.4.0

func (c *Config) Save() error

Save saves Config to local FS

type VerboseModeFlag

type VerboseModeFlag int

VerboseModeFlag is a type for capturing supported verbose mode formats. Implements pflag.Value interface.

const (
	// VerboseModeDisabled represents disabled verbose mode
	VerboseModeDisabled VerboseModeFlag = 0
	// VerboseModeSimple represents simple verbose mode (human friendly)
	VerboseModeSimple VerboseModeFlag = 1
	// VerboseModeTracing represents tracing verbose mode (output may be overwhelming)
	// In this mode http calls (request, response body, headers etc.) are logged
	VerboseModeTracing VerboseModeFlag = 2
)

func (VerboseModeFlag) AllowedOptions

func (o VerboseModeFlag) AllowedOptions() string

AllowedOptions returns list of allowed verbose mode options.

func (VerboseModeFlag) IsEnabled

func (o VerboseModeFlag) IsEnabled() bool

IsEnabled returns true if any verbose mode is enabled.

func (VerboseModeFlag) IsTracing

func (o VerboseModeFlag) IsTracing() bool

IsTracing returns true if tracing verbose mode is enabled.

func (VerboseModeFlag) IsValid

func (o VerboseModeFlag) IsValid() bool

IsValid returns true if VerboseModeFlag is valid.

func (*VerboseModeFlag) Set

func (o *VerboseModeFlag) Set(in string) error

Set format type to a given input. Required by pflag.Value interface.

func (VerboseModeFlag) String

func (o VerboseModeFlag) String() string

String returns the string representation of the Format. Required by pflag.Value interface.

func (*VerboseModeFlag) Type

func (o *VerboseModeFlag) Type() string

Type returns data type. Required by pflag.Value interface.

Directories

Path Synopsis
iox

Jump to

Keyboard shortcuts

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