Example #1
0
func getInput(o *mhopts.Options) (mh.Multihash, error) {
	args := flag.Args()
	if len(args) < 1 {
		return nil, fmt.Errorf("multihash is a required argument")
	}
	raw := args[0]

	h, err := mhopts.Decode(o.Encoding, raw)
	if err != nil {
		return nil, fmt.Errorf("fail to decode multihash '%s': %s", raw, err)
	}
	return h, nil
}
Example #2
0
func parseFlags(o *mhopts.Options) error {
	flag.Parse()
	if err := o.ParseError(); err != nil {
		return err
	}

	if checkRaw != "" {
		var err error
		checkMh, err = mhopts.Decode(o.Encoding, checkRaw)
		if err != nil {
			return fmt.Errorf("fail to decode check '%s': %s", checkRaw, err)
		}
	}

	return nil
}