internal

package
v0.0.0-...-7cd1858 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoggerFromContext

func LoggerFromContext(ctx context.Context) *slog.Logger

LoggerFromContext returns the logger from the context. It panics if the given context doesn't contain a logger.

func LoggerIntoContext

func LoggerIntoContext(ctx context.Context, logger *slog.Logger) context.Context

LoggerIntoContext creates a new context that contains the given logger.

func ToolIntoContext

func ToolIntoContext(ctx context.Context, tool *Tool) context.Context

ToolIntoContext creates a new context that contains the given tool.

Types

type Tool

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

Tool is an instance of the command line tool. Don't create instances of this directly, use the NewTool function instead.

func ToolFromContext

func ToolFromContext(ctx context.Context) *Tool

ToolFromContext returns the tool from the context. It panics if the given context doesn't contain the tool.

func (*Tool) Err

func (t *Tool) Err() io.Writer

Err returns the error output stream of the tool.

func (*Tool) In

func (t *Tool) In() io.Reader

In returns the input stream of the tool.

func (*Tool) Out

func (t *Tool) Out() io.Writer

Out returns the output stream of the tool.

func (*Tool) Run

func (t *Tool) Run(ctx context.Context) error

Run runs the tool.

type ToolBuilder

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

ToolBuilder contains the data and logic needed to create an instance of the command line tool. Don't create instances of this directly, use the NewTool function instead.

func NewTool

func NewTool() *ToolBuilder

NewTool creates a builder that can then be used to configure and create an instance of the command line tool.

func (*ToolBuilder) AddArg

func (b *ToolBuilder) AddArg(value string) *ToolBuilder

AddArg adds one command line argument.

func (*ToolBuilder) AddArgs

func (b *ToolBuilder) AddArgs(values ...string) *ToolBuilder

AddArgs adds a list of command line arguments.

func (*ToolBuilder) AddCommand

func (b *ToolBuilder) AddCommand(value func() *cobra.Command) *ToolBuilder

AddCommand adds a sub-command.

func (*ToolBuilder) AddCommands

func (b *ToolBuilder) AddCommands(values ...func() *cobra.Command) *ToolBuilder

AddCommands adds a list of sub-commands.

func (*ToolBuilder) Build

func (b *ToolBuilder) Build() (result *Tool, err error)

Build uses the data stored in the buider to create a new instance of the command line tool.

func (*ToolBuilder) SetArgs

func (b *ToolBuilder) SetArgs(values ...string) *ToolBuilder

SetArgs sets the list of command line arguments.

func (*ToolBuilder) SetErr

func (b *ToolBuilder) SetErr(value io.Writer) *ToolBuilder

SetErr sets the standard error output stream. This is mandatory.

func (*ToolBuilder) SetIn

func (b *ToolBuilder) SetIn(value io.Reader) *ToolBuilder

SetIn sets the standard input stream. This is mandatory.

func (*ToolBuilder) SetLogger

func (b *ToolBuilder) SetLogger(value *slog.Logger) *ToolBuilder

SetLogger sets the logger that the tool will use to write messages to the log. This is optional, and if not specified a new one will be created that writes JSON messages to a file `o2ims.log` file inside the tool cache directory.

func (*ToolBuilder) SetOut

func (b *ToolBuilder) SetOut(value io.Writer) *ToolBuilder

SetOut sets the standard output stream. This is mandatory.

Directories

Path Synopsis
cmd
Code generated by MockGen.
Code generated by MockGen.
alarms/api/generated
Package generated provides primitives to interact with the openapi HTTP API.
Package generated provides primitives to interact with the openapi HTTP API.
alarms/internal/resourceserver/generated
Package generated provides primitives to interact with the openapi HTTP API.
Package generated provides primitives to interact with the openapi HTTP API.
common/api/generated
Package generated provides primitives to interact with the openapi HTTP API.
Package generated provides primitives to interact with the openapi HTTP API.
resources/api/generated
Package generated provides primitives to interact with the openapi HTTP API.
Package generated provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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