Categorygithub.com/ungerik/go-structflag
modulepackage
0.0.0-20230216105120-fb412cd97707
Repository: https://github.com/ungerik/go-structflag.git
Documentation: pkg.go.dev

# README

go-structflag

Use the Go flag package on config structs

# Packages

No description provided by the author

# Functions

LoadFile loads a struct from a JSON or XML file.
LoadFileAndParseCommandLine loads the configuration from filename into structPtr and then parses the command line.
LoadFileIfExistsAndMustParseCommandLine same as LoadFileAndParseCommandLine but panics on error.
LoadJSON loads a struct from a JSON file.
LoadXML loads a struct from a XML file.
MustLoadFileAndParseCommandLine same as LoadFileAndParseCommandLine but panics on error.
MustParseCommandLine without loading any configuration.
Parse parses args, or if no args are given os.Args[1:].
ParseCommandLine without loading any configuration.
No description provided by the author
PrintConfig prints the flattened struct fields from structPtr to Output.
PrintUsage prints a description of all commands and flags of Set and Commands to Output.
PrintUsageTo prints a description of all commands and flags of Set and Commands to output.
SaveJSON saves a struct as a JSON file.
SaveXML saves a struct as a XML file.
StructVar defines the fields of a struct as flags.

# Constants

ErrCommandNotFound is returned when a command was not found.
ErrNotEnoughArguments is returned when a command is called with not enough aruments.

# Variables

AppName is the name of the application, defaults to os.Args[0].
CommandDescriptionColor is the color in which the command usage description will be printed on the screen.
Commands holds the global list of app commands.
CommandUsageColor is the color in which the command usage will be printed on the screen.
DefaultTag is the struct tag used to define the default value for the field (if that default value is different from the zero value).
FlagDescriptionColor is the color in which the flag usage description will be printed on the screen.
FlagUsageColor is the color in which the flag usage will be printed on the screen.
NameFunc is called as last operation for every flag name.
NameTag is the struct tag used to overwrite the struct field name as flag name.
NewFlags returns new Flags, defaults to flag.NewFlagSet(AppName, OnParseError).
OnParseError defines the behaviour if there is an error while parsing the flags.
Output used for printing usage.
No description provided by the author
ShorthandTag is the struct tag used to define the possix shorthand command line argument.
UsageTag is the struct tag used to give the usage description of a flag.

# Interfaces

Flags is the minimal interface structflag needs to work.
FlagsP supports github.com/ogier/pflag.

# Type aliases

CommandList helps to parse and execute commands from command line arguments.