Documentation ¶
Index ¶
- Constants
- Variables
- func GetMarkdownOptionOrDefault(val string, defaultBoolean bool) bool
- func GetPrettyOptionOrDefault(val string, defaultBoolean bool) bool
- func GetTimeDurationConfig(c *cli.Context, key string) time.Duration
- func RegisterTargetConfigurer(tc TargetConfigurer)
- func RegisterWriterConfigurer(wc WriterConfigurer)
- type CommandMethod
- type Configuration
- type Configurer
- type OutputFormat
- type Target
- type TargetConfigurer
- type WriterConfigurer
Constants ¶
View Source
const ( FormatCSV OutputFormat = "CSV" FormatTAB = "TAB" FormatJSON = "JSON" FormatTEMPLATE = "TEMPLATE" )
View Source
const ( MethodGet CommandMethod = "GET" MethodPost = "POST" MethodPut = "PUT" MethodDelete = "DELETE" MethodHead = "HEAD" MethodPatch = "PATCH" )
View Source
const FormatOptionTemplatePrefix string = "TEMPLATE="
Variables ¶
View Source
var ( ErrInvalidTargets error = errors.New("Must specify at least one target configurer that will return valid targets, such as a file or cli arguments.") ErrInvalidTimeoutFormat = errors.New("Timeout must conform to time.Duration format.") ErrInvalidRateFormat = errors.New("Rate must conform to time.Duration format.") ErrInvalidMethod = errors.New(fmt.Sprintf("Method unknown. Valid methods are %v", ValidMethods)) ErrInvalidFormat = errors.New(fmt.Sprintf("Output format unknown. Valid formats are %v", ValidFormats)) )
View Source
var DefaultHttpStatuses = map[string]int{ string(MethodGet): 200, string(MethodPost): 201, string(MethodPut): 200, string(MethodDelete): 200, string(MethodHead): 200, string(MethodPatch): 200, }
View Source
var ValidFormats = []string{"csv", "csv-md", "csv-no-color", "tab", "tab-md", "tab-no-color", "json", "json-compact", "template={{...}}"}
View Source
var ValidMethods = []string{"GET", "PUT", "POST", "DELETE", "HEAD", "PATCH"}
Functions ¶
func RegisterTargetConfigurer ¶
func RegisterTargetConfigurer(tc TargetConfigurer)
RegisterTargetConfigurer ...
func RegisterWriterConfigurer ¶
func RegisterWriterConfigurer(wc WriterConfigurer)
RegisterWriterConfigurer ...
Types ¶
type CommandMethod ¶
type CommandMethod string
type Configuration ¶
type Configuration struct { CommandName string Rate time.Duration FormatString string Output OutputFormat Pretty bool AggregateOutput bool Quiet bool NoHeader bool Markdown bool FailuresOnly bool StateChangeOnly bool Workers int Targets []*Target // contains filtered or unexported fields }
func GetConfiguration ¶
func GetConfiguration(c *cli.Context) (*Configuration, error)
func (*Configuration) ResultFormatter ¶
func (config *Configuration) ResultFormatter() output.ResultFormatter
func (*Configuration) Writer ¶
func (config *Configuration) Writer() io.Writer
func (*Configuration) WriterWithWriters ¶
func (config *Configuration) WriterWithWriters(writers ...io.Writer) io.Writer
type OutputFormat ¶
type OutputFormat string
func GetOutputFormatOrDefault ¶
func GetOutputFormatOrDefault(val string, defaultFormat OutputFormat) OutputFormat
type Target ¶
type Target struct { Label string Method CommandMethod Timeout time.Duration ExpectedStatus int URL string Headers map[string]string Extra map[string]interface{} }
func NewTarget ¶
func NewTarget(label string, urlString string, method CommandMethod, expectedStatus int) (*Target, error)
NewTarget creates a new config.Target object with the required fields.
func ParseTarget ¶
ParseTarget takes a string of format <url>|<method>|<status_code>|<label>|<header> and parses it into a config.Target object. URL is the only required field.
type TargetConfigurer ¶
type TargetConfigurer interface { Configurer GetTargets(c *cli.Context) ([]*Target, error) }
TargetConfigurer ...
func GetTargetConfigurers ¶
func GetTargetConfigurers() []TargetConfigurer
type WriterConfigurer ¶
type WriterConfigurer interface { Configurer GetWriter(c *cli.Context) io.Writer }
WriterConfigurer ...
func GetWriterConfigurers ¶
func GetWriterConfigurers() []WriterConfigurer
Click to show internal directories.
Click to hide internal directories.