package appargs

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

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

Index

Variables

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.

Source Files

appargs.go

Version
v0.12.9 (latest)
Published
Oct 30, 2024
Platform
linux/amd64
Imports
3 packages
Last checked
14 hours ago

Tools for package owners.