github.com/DaAlbrecht/cf-cli@v0.0.0-20231128151943-1fe19bb400b9/command/flag/timeout.go (about)

     1  package flag
     2  
     3  import (
     4  	"code.cloudfoundry.org/cli/types"
     5  	flags "github.com/jessevdk/go-flags"
     6  )
     7  
     8  type Timeout struct {
     9  	types.NullInt
    10  }
    11  
    12  func (t *Timeout) UnmarshalFlag(rawValue string) error {
    13  	err := t.ParseStringValue(rawValue)
    14  	if err != nil || t.Value < 1 {
    15  		return &flags.Error{
    16  			Type:    flags.ErrRequired,
    17  			Message: "Timeout must be an integer greater than or equal to 1",
    18  		}
    19  	}
    20  	return nil
    21  }
    22  
    23  func (t *Timeout) IsValidValue(val string) error {
    24  	return t.UnmarshalFlag(val)
    25  }