xflag

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package xflag provides a set of functions and utilities to extend the functionality of Go'give flag package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metadata added in v0.11.0

type Metadata struct {
	// Name is the name of the application.
	Name string

	// Description is a short description of the application.
	Description string

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

	// Synopsis is the command usage pattern shown in the usage section. Defaults to "[global options]" if empty.
	Synopsis string

	// Options is a list of options for the application.
	Options []Option
}

Metadata represents metadata for a command-line application.

func (*Metadata) Usage added in v0.11.0

func (m *Metadata) Usage() string

Usage returns the formatted usage information for the application.

The returned string contains the following sections:

  1. NAME: Application name and brief description.
  2. USAGE: Command-line usage pattern with global options.
  3. VERSION: Current version of the application.
  4. GLOBAL OPTIONS: Available command-line options with their details and default values.

func (*Metadata) Version added in v0.11.0

func (m *Metadata) Version() string

Version returns the version string of the application.

type Option added in v0.11.0

type Option struct {
	// Name is the name of the option.
	Name string

	// Shorthand is a single-character shorthand for the option.
	Shorthand string

	// Type is the type of value the option accepts (e.g., "FILE", "DIRECTORY").
	Type string

	// Description is a short description of the option.
	Description string

	// Default is the default value for the option.
	Default string
}

Option represents a single command-line option.

type StringSlice

type StringSlice []string

StringSlice is a custom flag type that allows for repeated string flags.

func (*StringSlice) Set

func (s *StringSlice) Set(value string) error

Set satisfies the flag.Value interface.

func (*StringSlice) String

func (s *StringSlice) String() string

String satisfies the flag.Value interface.

Jump to

Keyboard shortcuts

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