예제 #1
0
func fmtOutput(jirix *jiri.X, o string) string {
	_, width, err := textutil.TerminalSize()
	if err != nil {
		width = 80
	}
	if len(o) < width {
		return o
	}
	out := &bytes.Buffer{}
	w := textutil.NewUTF8WrapWriter(out, width)
	fmt.Fprint(w, o)
	w.Flush()
	return out.String()
}
예제 #2
0
파일: driver.go 프로젝트: 4shome/go.jiri
func runInfo(env *cmdline.Env, args []string) error {
	ctx := tool.NewContextFromEnv(env)
	profileNames := args
	if len(args) == 0 {
		profileNames = profiles.Managers()
	}
	_, width, err := textutil.TerminalSize()
	if err != nil {
		width = 80
	}
	w := textutil.NewUTF8LineWriter(ctx.Stdout(), width)
	defer w.Flush()
	for _, name := range profileNames {
		mgr := profiles.LookupManager(name)
		if mgr == nil {
			return fmt.Errorf("profile %q is not available", name)
		}
		fmt.Fprintf(w, "%s: %s\n\n", name, mgr.Info())
	}
	return nil
}