phelp

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package phelp provides the standard help parameter handling which includes printing the standard help message and any error reporting.

Index

Constants

View Source
const (
	Std helpStyle = iota
	Short
	GroupNamesOnly
)

helpStyle values can be one of:

Std meaning that the standard help message is generated
Full meaning that a more complete message is generated
Short meaning that a concise message is generated
GroupNamesOnly meaning that only group names should be shown

Variables

View Source
var SH = StdHelp{
	// contains filtered or unexported fields
}

SH is the instance of the standard help type

Functions

func ReportErrors

func ReportErrors(w io.Writer, 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 adds the standard arguments and processes them. This is the helper you are most likely to want and it is the one that is used by the paramset.New func.

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(w io.Writer, name string, 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 the messages and then a standardised usage message based on the parameters supplied to the param set. It then exits with an exit status of 1

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