example

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandPrint

type CommandPrint struct {
	Writer io.Writer
	// contains filtered or unexported fields
}

CommandPrint is an example command that prints positional and dashed arguments. It demonstrates the use of flags, argument validation, and error handling.

func (*CommandPrint) Description

func (cmd *CommandPrint) Description() string

Description returns a detailed description of the CommandPrint command.

func (*CommandPrint) Examples

func (cmd *CommandPrint) Examples() []string

Examples returns a slice of example usage strings for the CommandPrint command.

func (*CommandPrint) Execute

func (cmd *CommandPrint) Execute(_ context.Context, args, dashedArgs []string) error

Execute implements the main logic of the CommandPrint command. It processes positional and dashed arguments, validates the number of arguments, and prints the arguments along with their corresponding flag values (if any).

func (*CommandPrint) Flags

func (cmd *CommandPrint) Flags() []cli.Flag

Flags returns the command-line flags for the CommandPrint command. It defines flags for 'a', 'b', and 'c' options, using built-in flag types.

func (*CommandPrint) Usage

func (cmd *CommandPrint) Usage() string

Usage returns the usage string for the CommandPrint command, indicating the expected positional and dashed arguments.

type CommandRoot

type CommandRoot struct{}

CommandRoot is the root command for the example CLI application. It provides a general description of the application.

func (CommandRoot) Description

func (CommandRoot) Description() string

Description returns a description of the example CLI application.

func (CommandRoot) Execute

func (cmd CommandRoot) Execute(_ context.Context, _, _ []string) error

Execute is the main entry point for the root command. It simply returns an error that signals the help message to be displayed and sets the exit status to 0.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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