gencli

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Code generated by github.com/bcdxn/opencli@unknown version DO NOT EDIT.

Code generated by github.com/bcdxn/opencli@unknown version DO NOT EDIT.

Code generated by github.com/bcdxn/opencli@unknown version DO NOT EDIT.

Code generated by github.com/bcdxn/opencli@unknown version DO NOT EDIT.

Code generated by github.com/bcdxn/opencli@unknown version DO NOT EDIT.

Code generated by github.com/bcdxn/opencli@unknown version DO NOT EDIT.

Code generated by github.com/bcdxn/opencli@unknown version DO NOT EDIT.

Code generated by github.com/bcdxn/opencli@unknown version DO NOT EDIT.

Code generated by github.com/bcdxn/opencli@unknown version DO NOT EDIT.

Code generated by github.com/bcdxn/opencli@unknown version DO NOT EDIT.

Code generated by github.com/bcdxn/opencli@unknown version DO NOT EDIT.

Index

Constants

View Source
const (
	ExitCodeOK              int = 0
	ExitCodeInternalErr     int = 1
	ExitCodeBadUserInputErr int = 2
)

Variables

This section is empty.

Functions

func DefaultHelpFunc

func DefaultHelpFunc(a ActionsInterface, cmd *spec.CommandItem)

DefaultHelpFunc renders contextual help for cmd to the actions IOStreams output.

func DefaultUsageFunc

func DefaultUsageFunc(a ActionsInterface, cmd *spec.CommandItem) error

DefaultUsageFunc renders contextual usage for cmd to the actions IOStreams output.

func NewCmdOcli

func NewCmdOcli(a ActionsInterface) *cobra.Command

func NewCmdOcliCheck

func NewCmdOcliCheck(a ActionsInterface) *cobra.Command

func NewCmdOcliGen

func NewCmdOcliGen(a ActionsInterface) *cobra.Command

func NewCmdOcliGenCli

func NewCmdOcliGenCli(a ActionsInterface) *cobra.Command

func NewCmdOcliGenDocs

func NewCmdOcliGenDocs(a ActionsInterface) *cobra.Command

func Run

func Run(ctx context.Context, actions ActionsInterface) int

Run executes the root cobra command and returns an exit code.

Types

type ActionsInterface

type ActionsInterface interface {
	OcliCheck(ctx context.Context, args OcliCheckArgs, flags OcliCheckFlags) error
	OcliGenDocs(ctx context.Context, args OcliGenDocsArgs, flags OcliGenDocsFlags) error
	OcliGenCli(ctx context.Context, args OcliGenCliArgs, flags OcliGenCliFlags) error
	HelpFunc(cmd *spec.CommandItem)
	UsageFunc(cmd *spec.CommandItem) error
	IOStreams() IOStreams
	Version() string
}

ActionsInterface defines all actions the ocli CLI supports.

type CLIError

type CLIError struct {
	Code      int
	Message   string
	UsageFunc UsageFunc
}

CLIError represents a CLI error with an exit code and an optional usage function.

func BadUserInput

func BadUserInput(message string, usageFn UsageFunc) *CLIError

BadUserInput creates a new CLIError with the bad user input exit code.

func InternalError

func InternalError(message string, usageFn UsageFunc) *CLIError

InternalError creates a new CLIError with the internal error exit code.

func (CLIError) Error

func (err CLIError) Error() string

type DefaultIOStreams

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

DefaultIOStreams is the default implementation of IOStreams backed by os.Stdin/Stdout/Stderr.

func (DefaultIOStreams) ErrOut

func (ios DefaultIOStreams) ErrOut() FileWriter

func (DefaultIOStreams) In

func (ios DefaultIOStreams) In() FileReader

func (DefaultIOStreams) Out

func (ios DefaultIOStreams) Out() FileWriter

func (DefaultIOStreams) TerminalSize

func (ios DefaultIOStreams) TerminalSize() (int, int, error)

func (DefaultIOStreams) TerminalTheme

func (ios DefaultIOStreams) TerminalTheme() string

type DefaultTerminal

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

DefaultTerminal is the default Terminal implementation backed by the real OS terminal.

func (*DefaultTerminal) Is256ColorSupported

func (t *DefaultTerminal) Is256ColorSupported() bool

func (*DefaultTerminal) IsTerminalOutput

func (t *DefaultTerminal) IsTerminalOutput() bool

func (*DefaultTerminal) IsTrueColorSupported

func (t *DefaultTerminal) IsTrueColorSupported() bool

func (*DefaultTerminal) Size

func (t *DefaultTerminal) Size() (int, int, error)

func (*DefaultTerminal) Theme

func (t *DefaultTerminal) Theme() string

type FileReader

type FileReader interface {
	io.ReadCloser
	Fd() uintptr
}

FileReader is an io.ReadCloser that exposes the underlying file descriptor.

type FileWriter

type FileWriter interface {
	io.Writer
	Fd() uintptr
}

FileWriter is an io.Writer that exposes the underlying file descriptor.

type IOStreams

type IOStreams interface {
	In() FileReader
	Out() FileWriter
	ErrOut() FileWriter
	TerminalTheme() string
	TerminalSize() (int, int, error)
}

IOStreams provides access to the standard I/O streams.

func DefaultIOS

func DefaultIOS() IOStreams

DefaultIOS returns an IOStreams backed by the real os.Stdin/Stdout/Stderr.

func TestIOS

func TestIOS() (IOStreams, *bytes.Buffer, *bytes.Buffer, *bytes.Buffer)

TestIOS returns an IOStreams backed by bytes.Buffer for use in tests.

type OcliCheckArgs

type OcliCheckArgs struct {
	PathToSpec string
}

OcliCheckArgs holds the positional arguments for the OcliCheck action.

type OcliCheckFlags

type OcliCheckFlags struct {
	FailOnErr bool
}

OcliCheckFlags holds the flag values for the OcliCheck action.

type OcliGenCliArgs

type OcliGenCliArgs struct {
	PathToSpec string
}

OcliGenCliArgs holds the positional arguments for the OcliGenCli action.

type OcliGenCliFlags

type OcliGenCliFlags struct {
	Out       string
	Framework OcliGenCliFramework
}

OcliGenCliFlags holds the flag values for the OcliGenCli action.

type OcliGenCliFramework

type OcliGenCliFramework string

OcliGenCliFramework represents the allowed values for the Framework flag.

const (
	OcliGenCliFrameworkCobra     OcliGenCliFramework = "cobra"
	OcliGenCliFrameworkUrfavecli OcliGenCliFramework = "urfavecli"
	OcliGenCliFrameworkYargs     OcliGenCliFramework = "yargs"
)

func (OcliGenCliFramework) IsValid

func (v OcliGenCliFramework) IsValid() bool

type OcliGenDocsArgs

type OcliGenDocsArgs struct {
	PathToSpec string
}

OcliGenDocsArgs holds the positional arguments for the OcliGenDocs action.

type OcliGenDocsFlags

type OcliGenDocsFlags struct {
	Format   OcliGenDocsFormat
	Out      string
	NoFooter bool
	NoBadge  bool
}

OcliGenDocsFlags holds the flag values for the OcliGenDocs action.

type OcliGenDocsFormat

type OcliGenDocsFormat string

OcliGenDocsFormat represents the allowed values for the Format flag.

const (
	OcliGenDocsFormatMarkdown  OcliGenDocsFormat = "markdown"
	OcliGenDocsFormatHtmlPage  OcliGenDocsFormat = "html-page"
	OcliGenDocsFormatHtmlEmbed OcliGenDocsFormat = "html-embed"
	OcliGenDocsFormatMan       OcliGenDocsFormat = "man"
)

func (OcliGenDocsFormat) IsValid

func (v OcliGenDocsFormat) IsValid() bool

type Terminal

type Terminal interface {
	IsTerminalOutput() bool
	Is256ColorSupported() bool
	IsTrueColorSupported() bool
	Theme() string
	Size() (int, int, error)
}

Terminal provides terminal capability detection.

type UsageFunc

type UsageFunc func() error

UsageFunc is a function that renders the usage for a command.

type ValidationError

type ValidationError struct {
	Message string
}

ValidationError represents an error that occurred during action validation.

func NewValidationError

func NewValidationError(message string) *ValidationError

NewValidationError creates a new ValidationError.

func (ValidationError) Error

func (err ValidationError) Error() string

Jump to

Keyboard shortcuts

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