phelp

package
v6.1.6 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: MIT Imports: 23 Imported by: 1

Documentation

Overview

Package phelp provides the standard help parameter handling which includes printing the standard help message and any error reporting. It is not anticipated that any of the interfaces will be called directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommonParamsGroupNamePrefix

func CommonParamsGroupNamePrefix() string

CommonParamsGroupNamePrefix returns the prefix used to start the names of all the common parameter groups

func ReportErrors

func ReportErrors(twc *twrap.TWConf, name string, errMap param.ErrMap)

ReportErrors reports the errors (if any) to the writer. It can be used by any Helper and is used by the StdHelp instance.

Types

type StdHelp

type StdHelp struct {
	// contains filtered or unexported fields
}

StdHelp implements the Helper interface. It records the parameter values set by the common parameters and proivides methods for generating the help message. This is the helper you should use unless you are testing the package or have some requirement to provide help other than at the command line.

It will be used automatically if you create your param.PSet using the paramset.New function (recommended).

func NewStdHelp

func NewStdHelp() *StdHelp

NewStdHelp returns a pointer to a well-constructed instance of the standard help type ready to be used as the helper for a new param.PSet (the standard paramset.New() function will use this)

func (*StdHelp) AddParams

func (h *StdHelp) AddParams(ps *param.PSet)

AddParams will add the help parameters into the parameter set

func (StdHelp) ErrorHandler

func (h StdHelp) ErrorHandler(ps *param.PSet, errMap param.ErrMap)

ErrorHandler will, by default, check for errors and if there are any report them and exit. It will respect the flags for controlling reporting of errors and exiting; these flags can be set by means of standard arguments as added by the StdHelp AddParams method, see the standard help message for details. It is typically called from the Parse(...) method being passed the PSet error writer, the program name and the PSet error map

func (StdHelp) Help

func (h StdHelp) Help(ps *param.PSet, messages ...string)

Help prints any messages and then a standardised usage message based on the parameters supplied to the param set. If it is called directly (that is if the help style is set to noHelp) then the output will be written to the param.PSet's error writer (by default stderr) rather than to its standard writer (stdout) and os.Exit will be called with an exit status of 1 to indicate an error.

func (StdHelp) ProcessArgs

func (h StdHelp) ProcessArgs(ps *param.PSet)

ProcessArgs will process the values set after parsing is complete. This is where any StdHelp parameters (as added by the StdHelp AddParams method) will be processed.

Jump to

Keyboard shortcuts

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