cli

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package cli provides a base struct for creating CLI applications using Cobra. It contains common functionality for creating CLI applications, such as providing a logger, adding commands and running the root command.

Index

Constants

View Source
const Indentation = `  `

Variables

This section is empty.

Functions

func Examples

func Examples(s string) string

Examples normalizes a command's examples to follow the conventions.

func LongDesc

func LongDesc(s string) string

LongDesc normalizes a command's long description to follow the conventions.

func NewCLILogger

func NewCLILogger(logLevel zapcore.Level) (logger.Logger, error)

func NewLogger

func NewLogger(level zapcore.Level) (logger.Logger, error)

NewLogger creates a new logger instance from chainlink-common. This is a helper function to initialize a logger to provide to `NewBase`.

Types

type Base

type Base struct {
	Log logger.Logger
	// contains filtered or unexported fields
}

Base is a base struct for creating CLI applications using Cobra. This should be embedded into a struct that contains the specific commands for the CLI application.

func NewBase

func NewBase(log logger.Logger, rootCmd *cobra.Command) *Base

NewBase creates a new CLIBase instance.

func (*Base) AddCommand

func (base *Base) AddCommand(cmds ...*cobra.Command)

AddCommand adds one or more commands to the root command of the CLI application.

func (*Base) RootCmd

func (base *Base) RootCmd() *cobra.Command

RootCmd returns the root command of the CLI application.

func (*Base) Run

func (base *Base) Run() error

Run executes the root command of the CLI application.

Jump to

Keyboard shortcuts

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