package xflag

import "git.sr.ht/~jamesponddotco/xstd-go/xflag"

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

Index

Types

type Metadata

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

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

func (m *Metadata) Version() string

Version returns the version string of the application.

type Option

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.

Source Files

metadata.go string_slice.go xflag.go

Version
v0.13.1 (latest)
Published
Jan 29, 2025
Platform
linux/amd64
Imports
3 packages
Last checked
4 days ago

Tools for package owners.