github.com/liamawhite/cli-with-i18n@v6.32.1-0.20171122084555-dede0a5c3448+incompatible/command/flag/docker.go (about)

     1  package flag
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/docker/distribution/reference"
     7  	flags "github.com/jessevdk/go-flags"
     8  )
     9  
    10  type DockerImage struct {
    11  	Path string
    12  }
    13  
    14  func (d *DockerImage) UnmarshalFlag(val string) error {
    15  	_, err := reference.Parse(val)
    16  	if err != nil {
    17  		return &flags.Error{
    18  			Type:    flags.ErrRequired,
    19  			Message: fmt.Sprintf("invalid docker reference: %s", err.Error()),
    20  		}
    21  	}
    22  	d.Path = val
    23  	return nil
    24  }