示例#1
0
文件: pp.go 项目: prataprc/gocbsh
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
文件: get.go 项目: prataprc/gocbsh
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
}