opts

package
v0.4.0-rc3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2016 License: MIT, MIT Imports: 11 Imported by: 0

README

mhopts - multihash options for writing commands

mhopts is a small package that helps to write commands which may take multihash options. Check it out in action:

Godoc: https://godoc.org/github.com/jbenet/go-multihash/opts

Documentation

Overview

Package opts helps to write commands which may take multihash options.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMatch = errors.New("multihash checksums did not match")
)

package errors

View Source
var FlagValues = struct {
	Encodings  []string
	Algorithms []string
}{
	Encodings:  []string{"raw", "hex", "base58", "base64"},
	Algorithms: []string{"sha1", "sha2-256", "sha2-512", "sha3"},
}

FlagValues are the values the various option flags can take.

Functions

func Decode

func Decode(encoding, digest string) (mh.Multihash, error)

func Encode

func Encode(encoding string, hash mh.Multihash) (string, error)

Types

type Options

type Options struct {
	Encoding      string
	Algorithm     string
	AlgorithmCode int
	Length        int
	// contains filtered or unexported fields
}

Options is a struct used to parse cli flags.

func SetupFlags

func SetupFlags(f *flag.FlagSet) *Options

SetupFlags adds multihash related options to given flagset.

func (*Options) Check

func (o *Options) Check(r io.Reader, h1 mh.Multihash) error

Check reads all the data in r, calculates its multihash, and checks it matches h1

func (*Options) Multihash

func (o *Options) Multihash(r io.Reader) (mh.Multihash, error)

Multihash reads all the data in r and calculates its multihash.

func (*Options) Parse

func (o *Options) Parse(args []string) error

Parse parses the values of flags from given argument slice. It is equivalent to flags.Parse(args)

func (*Options) ParseError

func (o *Options) ParseError() error

ParseError checks the parsed options for errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL