Beispiel #1
0
// formatNodeLong formats the node as a string for output to the console.
func (h *LsHandler) formatNodeLong(n *etcd.Node, w LsColumnWidths) string {
	typeValue := SymbolTypeKeys
	if !n.Dir {
		typeValue = SymbolTypeObjects
	}

	prefix := ""
	postfix := ""
	if h.use_colors {
		if n.Dir {
			prefix = env.ColorPrefixCode(h.colors.Key)
		} else {
			fmt.Println(h.colors.Object)
			prefix = env.ColorPrefixCode(h.colors.Object)
		}
		postfix = env.ColorPostfixCode()
	}

	return fmt.Sprintf(
		"%*d %*d %*d %s: %s%s%s\n",
		w.CreatedIndex,
		n.CreatedIndex,
		w.ModifiedIndex,
		n.ModifiedIndex,
		w.TTL,
		n.TTL,
		typeValue,
		prefix,
		path.Base(n.Key),
		postfix,
	)
}
Beispiel #2
0
func (h *LsHandler) formatNodeShort(n *etcd.Node, w LsColumnWidths) string {
	prefix, postfix := "", ""
	if h.use_colors {
		if n.Dir {
			prefix = env.ColorPrefixCode(h.colors.Key)
		} else {
			prefix = env.ColorPrefixCode(h.colors.Object)
		}
		postfix = env.ColorPostfixCode()
	}

	return fmt.Sprintf(
		"%s%-*s%s",
		prefix,
		w.Keys,
		path.Base(n.Key),
		postfix,
	)
}