Exemplo n.º 1
0
// KeyListTextMarshaler outputs a KeyList as plaintext, one key per line
func KeyListTextMarshaler(res cmds.Response) ([]byte, error) {
	output := res.Output().(*KeyList)
	s := ""
	for _, key := range output.Keys {
		s += key.B58String() + "\n"
	}
	return []byte(s), nil
}
Exemplo n.º 2
0
func bootstrapMarshaler(res cmds.Response) ([]byte, error) {
	v, ok := res.Output().(*BootstrapOutput)
	if !ok {
		return nil, u.ErrCast()
	}

	var buf bytes.Buffer
	err := bootstrapWritePeers(&buf, "", v.Peers)
	return buf.Bytes(), err
}
Exemplo n.º 3
0
func stringListMarshaler(res cmds.Response) ([]byte, error) {
	list, ok := res.Output().(*stringList)
	if !ok {
		return nil, errors.New("failed to cast []string")
	}

	var buf bytes.Buffer
	for _, s := range list.Strings {
		buf.Write([]byte(s))
		buf.Write([]byte("\n"))
	}
	return buf.Bytes(), nil
}
Exemplo n.º 4
0
func MessageTextMarshaler(res cmds.Response) ([]byte, error) {
	return []byte(res.Output().(*MessageOutput).Message), nil
}