urfave

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package urfave integrates typed configuration files with urfave/cli/v3.

NewConfigFlag provides a global --config flag that updates a ConfigFile before command hooks run. NewConfigCommand provides show, path, validate, and init subcommands.

Example
package main

import (
	"fmt"

	urfavecli "github.com/urfave/cli/v3"
	"github.com/vekio/config"
	"github.com/vekio/config/urfave"
)

type exampleConfig struct{}

func (exampleConfig) Validate() error { return nil }

func main() {
	file, err := config.NewYAMLConfigFile[exampleConfig]("example", "config.yml")
	if err != nil {
		panic(err)
	}

	app := &urfavecli.Command{
		Name:     "example",
		Flags:    []urfavecli.Flag{urfave.NewConfigFlag(file)},
		Commands: []*urfavecli.Command{urfave.NewConfigCommand(file, exampleConfig{})},
	}

	fmt.Println(app.Name, app.Flags[0].Names()[0], app.Commands[0].Name)
}
Output:
example config config

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConfigCommand

func NewConfigCommand[T config.Validatable](file *config.ConfigFile[T], defaultData T) *urfavecli.Command

NewConfigCommand creates a reusable config command with show, path, validate, and init subcommands. Invoking config without a subcommand displays help.

func NewConfigFlag

func NewConfigFlag[T config.Validatable](file *config.ConfigFile[T]) urfavecli.Flag

NewConfigFlag creates a global --config flag that overrides file's path when explicitly set by the client application.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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