// Parse parses the given args into Inputs.
Parse parses the given args into Inputs.
// Parse parses the given args into Inputs .
func Parse(name string, args []string) (*Input, error) {
	fs := newFSet(name)
	fs.SetOutput(ioutil.Discard)
	if err := fs.Parse(args); err != nil {
		return nil, fmt.Errorf("parse flags: %w", err)
	}
	if fs.host == nil || fs.port == nil || fs.dir == nil || *fs.host == "" || *fs.port == "" || *fs.dir == "" {
		return nil, fmt.Errorf("host, port and dir are required")
	}
	if (fs.key == nil || *fs.key == "") && (fs.cert != nil && *fs.cert != "") {
		return nil, fmt.Errorf("key is required along with the cert")
	}
	if (fs.key != nil && *fs.key != "") && (fs.cert == nil || *fs.cert == "") {
		return nil, fmt.Errorf("cert is required along with the key")
	}
	inp := Input{
		Help:     *fs.help,
		Dir:      *fs.dir,
		Host:     *fs.host,
		Port:     *fs.port,
		CertFile: *fs.cert,
		KeyFile:  *fs.key,
		Quiet:    *fs.quiet,
	}
	return &inp, nil
}
func Parse ( name string , args [ ] string ) ( * Input , error ) { fs := newFSet ( name ) fs . SetOutput ( ioutil . Discard ) if err := fs . Parse ( args ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } if fs . host == nil || fs . port == nil || fs . dir == nil || * fs . host == " " || * fs . port == " " || * fs . dir == " " { return nil , fmt . Errorf ( " " ) } if ( fs . key == nil || * fs . key == " " ) && ( fs . cert != nil && * fs . cert != " " ) { return nil , fmt . Errorf ( " " ) } if ( fs . key != nil && * fs . key != " " ) && ( fs . cert == nil || * fs . cert == " " ) { return nil , fmt . Errorf ( " " ) } inp := Input { Help : * fs . help , Dir : * fs . dir , Host : * fs . host , Port : * fs . port , CertFile : * fs . cert , KeyFile : * fs . key , Quiet : * fs . quiet , } return & inp , nil }
Parse parses the given args into Inputs.
Parse parses the given args into Inputs .