app

package
v0.0.0-...-77d485b Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package app provides structures and functions to create and manage CLI applications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	*cli.App
	// contains filtered or unexported fields
}

App represents an application with CLI commands. It embeds *cli.App from the urfave/cli package and adds context support.

func New

func New(ctx context.Context, desc Descriptor) (*App, error)

New initializes a new App instance with the provided context and descriptor. It returns an error if the initialization fails.

func NewDefaultApp

func NewDefaultApp(ctx context.Context, version string) (*App, error)

NewDefaultApp creates and returns a new instance of the App configured with default settings. This function sets up the application with predefined descriptors such as the application name, usage, version, and authors. The ctx parameter is the context to control the application lifecycle, while the version parameter specifies the current version of the application. It returns a pointer to an initialized App and any error encountered during the App creation process.

func (*App) LoadDefaultLogger

func (a *App) LoadDefaultLogger() error

func (*App) LoadDefaultOptions

func (a *App) LoadDefaultOptions(paths []string, skipFlags bool) (*options.Options, error)

func (*App) RegisterCommands

func (a *App) RegisterCommands(commands []*cli.Command) error

RegisterCommands adds a slice of *cli.Command to the application. It returns an error if the application is not initialized.

func (*App) Run

func (a *App) Run(args []string) error

Run executes the application with the provided command-line arguments. It delegates to *cli.App's Run method and returns any errors encountered.

type Descriptor

type Descriptor struct {
	Name        string
	Version     string
	HelpName    string
	Description string
	Usage       string
	Authors     []*cli.Author
}

Descriptor holds basic information about the CLI application.

Jump to

Keyboard shortcuts

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