beam/examples/beamsh: 'emit' supports key=value syntax to compose arbitrary objects

Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
This commit is contained in:
Solomon Hykes 2014-03-27 18:27:58 -07:00
Родитель 2b81fb8424
Коммит 6d9cdbf24f
1 изменённых файлов: 1 добавлений и 22 удалений

Просмотреть файл

@ -452,7 +452,7 @@ func GetHandler(name string) Handler {
}
} else if name == "emit" {
return func(args []string, in *net.UnixConn, out *net.UnixConn) {
beam.Send(out, data.Empty().Set("foo", args[1:]...).Bytes(), nil)
beam.Send(out, data.Parse(args[1:]).Bytes(), nil)
}
} else if name == "print" {
return func(args []string, in *net.UnixConn, out *net.UnixConn) {
@ -631,27 +631,6 @@ func connToFile(conn net.Conn) (f *os.File, err error) {
return f, err
}
// 'status' is a notification of a job's status.
//
func parseEnv(args []string) ([]string, map[string]string) {
var argsOut []string
env := make(map[string]string)
for _, word := range args[1:] {
if strings.Contains(word, "=") {
kv := strings.SplitN(word, "=", 2)
key := kv[0]
var val string
if len(kv) == 2 {
val = kv[1]
}
env[key] = val
} else {
argsOut = append(argsOut, word)
}
}
return argsOut, env
}
type Msg struct {
payload []byte
attachment *os.File