...

Package appargs

import "github.com/Microsoft/hcsshim/internal/appargs"
Overview
Index

Overview ▾

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

Variables

ErrInvalidUsage is returned when there is a validation error.

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

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.

type Validator

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

type Validator = func([]string) int

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.