コード例 #1
0
ファイル: reader_cmdline.go プロジェクト: vanadium/go.jiri
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
}