appargs

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package appargs provides argument validation routines for use with github.com/urfave/cli.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidUsage = errors.New("invalid command usage")

ErrInvalidUsage is returned when there is a validation error.

Functions

func NonEmptyString

func NonEmptyString(args []string) int

NonEmptyString is a validator for non-empty strings.

func String

func String(args []string) int

String is a validator for strings.

func Validate

func Validate(vs ...Validator) cli.BeforeFunc

Validate can be used as a command's Before function to validate the arguments to the command.

Types

type Validator

type Validator = func([]string) int

Validator is an argument validator function. It returns the number of arguments consumed or -1 on error.

func Int

func Int(base int, min int, max int) Validator

Int returns a validator for integers.

func Optional

func Optional(v Validator) Validator

Optional returns a validator that treats an argument as optional.

func Rest

func Rest(v Validator) Validator

Rest returns a validator that validates each of the remaining arguments.

Jump to

Keyboard shortcuts

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