Пример #1
0
func (cmd *PpCommand) ppForCbsh(cbsh *shells.Cbsh, c *api.Context) (err error) {
	var s string

	cmd.indexArgParse(c.Line)

	switch {
	case ppCbshOption.bucket:
		s, err = api.PrettyPrint(*cbsh.Bucket, "")
		fmt.Fprintln(c.W, s)
	case ppCbshOption.pool:
		s, err = api.PrettyPrint(cbsh.Pool, "")
		fmt.Fprintln(c.W, s)
	}
	return
}
Пример #2
0
func getForCbsh(cbsh *shells.Cbsh, c *api.Context) (err error) {
	var ob interface{}
	parts := api.SplitArgs(c.Line, " ")
	if cbsh.Bucket == nil {
		err = fmt.Errorf("Not connected to bucket")
	} else if len(parts) < 2 {
		err = fmt.Errorf("Need argument to get")
	} else if err = cbsh.Bucket.Get(parts[1], &ob); err == nil {
		var s string
		s, err = api.PrettyPrint(ob, "")
		fmt.Fprintf(c.W, "%v\n", s)
	}
	return
}