root

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2025 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RootCommand

type RootCommand struct {
	command.Command

	// Version is the version of the application.
	Version string

	// Commands maps command names to commands.
	Commands map[string]*command.Command
}

RootCommand represents the root command. Can be assigned while creating a new root command with NewRootCommand.

func NewRootCommand

func NewRootCommand(name, usage, description string, version string) *RootCommand

NewRootCommand creates a new root command.

Parameters:

  • name: The name of the root command.
  • usage: The usage of the root command.
  • description: The description of the root command.
  • version: The version of the application.

Returns:

  • A pointer to a new RootCommand.

func (*RootCommand) AddAliasCommand

func (rc *RootCommand) AddAliasCommand(alias, targetCmd string)

AddAliasCommand adds an alias for a command.

Parameters:

  • alias: The name of the alias.
  • targetCmd: The name of the target command.

func (*RootCommand) AddAliasSubCommand

func (rc *RootCommand) AddAliasSubCommand(alias, targetCmd, targetSubCmd string)

AddAliasSubCommand adds an alias for a subcommand of a command.

Parameters:

  • alias: The name of the alias.
  • targetCmd: The name of the target command.
  • targetSubCmd: The name of the target subcommand.

func (*RootCommand) AddCommand

func (rc *RootCommand) AddCommand(cmd *command.Command)

AddCommand adds a subcommand.

Parameters:

  • cmd: The subcommand to add.

func (*RootCommand) Execute

func (rc *RootCommand) Execute() error

Execute runs the main command.

Returns:

  • An error, if an error occurs during execution.

func (*RootCommand) PrintHelp

func (rc *RootCommand) PrintHelp()

PrintHelp prints the help message for the root command.

Jump to

Keyboard shortcuts

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