cli

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package session wraps ocm session parameters to be accessed during cli commands. For example both the active connection and logger can be retrieved from the current session.

Index

Constants

View Source
const (
	LogLevelError = iota
	LogLevelWarn
	LogLevelInfo
	LogLevelDebug
)

Variables

View Source
var ErrNoConfigurationLoaded = errors.New("no configuration loaded")

Functions

func LogLevel

func LogLevel(verbosity int) log.Level

LogLevel converts an integer value to the appropriate log Level.

func ParseOrder

func ParseOrder(maybeOrder string) ocm.Order

func ParseTime

func ParseTime(maybeTime string) (time.Time, error)

func PromptYesOrNo added in v0.2.0

func PromptYesOrNo(out io.Writer, in io.Reader, msg string) bool

Types

type CommonOptions

type CommonOptions struct {
	Columns   string
	NoHeaders bool
	NoColor   bool
}

func (*CommonOptions) AddColumnsFlag

func (c *CommonOptions) AddColumnsFlag(flags *pflag.FlagSet)

func (*CommonOptions) AddNoColorFlag added in v0.2.2

func (c *CommonOptions) AddNoColorFlag(flags *pflag.FlagSet)

func (*CommonOptions) AddNoHeadersFlag

func (c *CommonOptions) AddNoHeadersFlag(flags *pflag.FlagSet)

func (*CommonOptions) DefaultColumns

func (c *CommonOptions) DefaultColumns(cols string)

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config wraps an 'ocm-cli' config object and it's fields/methods.

func LoadConfig

func LoadConfig() (Config, error)

LoadConfig loads an existing 'ocm.json' file and returns a Config object if possible.

func (Config) ClientID

func (c Config) ClientID() string

ClientID returns the user's client id as configured.

func (Config) IsEmpty

func (c Config) IsEmpty() bool

IsEmpty returns true if there is no configuration file or if no credentials are present with which to start a session.

func (Config) Pager

func (c Config) Pager() string

Pager returns the configured paging application to pipe output to.

func (Config) URL

func (c Config) URL() string

URL returns the configured OCM URL.

type FilterOptions

type FilterOptions struct {
	Order ocm.Order

	Before time.Time

	After time.Time
	// contains filtered or unexported fields
}

func (*FilterOptions) AddAfterFlag

func (f *FilterOptions) AddAfterFlag(flags *pflag.FlagSet)

func (*FilterOptions) AddBeforeFlag

func (f *FilterOptions) AddBeforeFlag(flags *pflag.FlagSet)

func (*FilterOptions) AddOrderFlag

func (f *FilterOptions) AddOrderFlag(flags *pflag.FlagSet)

func (*FilterOptions) AfterUsage

func (f *FilterOptions) AfterUsage(usg string)

func (*FilterOptions) BeforeUsage

func (f *FilterOptions) BeforeUsage(usg string)

func (*FilterOptions) OrderDefault

func (f *FilterOptions) OrderDefault(ord string)

func (*FilterOptions) OrderUsage

func (f *FilterOptions) OrderUsage(usg string)

func (*FilterOptions) ParseFilterOptions

func (f *FilterOptions) ParseFilterOptions() error

type SearchOptions

type SearchOptions struct {
	Search string
	// contains filtered or unexported fields
}

func (*SearchOptions) AddSearchFlag

func (s *SearchOptions) AddSearchFlag(flags *pflag.FlagSet)

func (*SearchOptions) SearchUsage

func (s *SearchOptions) SearchUsage(usg string)

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session provides access to the session-bound parameters for an invocation of this plug-in.

func NewSession

func NewSession() (Session, error)

NewSession loads an ocm configuration created after the user runs 'ocm login' and starts a connection to ocm. A logger with session context is also made available to callers of NewSession. An error is returned if a configuration cannot be loaded or if a connection cannot be made to OCM. Otherwise a pointer to a session object is returned.

func (*Session) Conn

func (s *Session) Conn() *sdk.Connection

Conn returns the OCM connection for the current session.

func (*Session) End

func (s *Session) End()

End releases any open session resources and logs any errors that may occur during this process.

func (*Session) Logger

func (s *Session) Logger() log.Interface

Logger returns a log instance with session context added.

func (*Session) Pager added in v0.2.2

func (s *Session) Pager() string

Pager returns the pager binary loaded for the current session.

Jump to

Keyboard shortcuts

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