當前位置: 首頁>>代碼示例>>Golang>>正文


Golang uitable.New函數代碼示例

本文整理匯總了Golang中github.com/gosuri/uitable.New函數的典型用法代碼示例。如果您正苦於以下問題:Golang New函數的具體用法?Golang New怎麽用?Golang New使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了New函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: execListCommand

// Executes the "list" command
func execListCommand(c *cli.Context) error {
	klient := newEtcdMinionClientFromFlags(c)

	cFlag := c.String("with-classifier")
	minions, err := parseClassifierPattern(klient, cFlag)

	// Ignore errors about missing minion directory
	if err != nil {
		if eerr, ok := err.(client.Error); !ok || eerr.Code != client.ErrorCodeKeyNotFound {
			return cli.NewExitError(err.Error(), 1)
		}
	}

	if len(minions) == 0 {
		return nil
	}

	table := uitable.New()
	table.MaxColWidth = 80
	table.AddRow("MINION", "NAME")
	for _, minion := range minions {
		name, err := klient.MinionName(minion)
		if err != nil {
			return cli.NewExitError(err.Error(), 1)
		}

		table.AddRow(minion, name)
	}

	fmt.Println(table)

	return nil
}
開發者ID:dnaeon,項目名稱:gru,代碼行數:34,代碼來源:list.go

示例2: execLastseenCommand

// Executes the "lastseen" command
func execLastseenCommand(c *cli.Context) error {
	client := newEtcdMinionClientFromFlags(c)

	cFlag := c.String("with-classifier")
	minions, err := parseClassifierPattern(client, cFlag)

	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}

	table := uitable.New()
	table.MaxColWidth = 80
	table.AddRow("MINION", "LASTSEEN")
	for _, minion := range minions {
		lastseen, err := client.MinionLastseen(minion)
		if err != nil {
			return cli.NewExitError(err.Error(), 1)
		}

		table.AddRow(minion, time.Unix(lastseen, 0))
	}

	fmt.Println(table)

	return nil
}
開發者ID:dnaeon,項目名稱:gru,代碼行數:27,代碼來源:lastseen.go

示例3: cmdListFull

func cmdListFull(s *StoreChan) error {
	lst, err := s.ListFull()
	if err != nil {
		return fmt.Errorf("Error listing user: %s\n", err)
	}

	var keys []string
	for k := range lst {
		keys = append(keys, k)
	}
	sort.Strings(keys)

	table := uitable.New()
	table.MaxColWidth = 80
	table.AddRow("NAME", "TYPE", "LAST-CHANGED", "VALID", "SUPPORTED", "FORMAT", "PARAMS")
	for _, k := range keys {
		t := "user"
		if lst[k].IsAdmin {
			t = "admin"
		}
		table.AddRow(k, t, lst[k].LastChanged.String(), lst[k].IsValid, lst[k].IsSupported, lst[k].FormatID, lst[k].FormatParams)
	}
	fmt.Println(table)
	return nil
}
開發者ID:whawty,項目名稱:auth,代碼行數:25,代碼來源:main.go

示例4: cmdListSupported

func cmdListSupported(s *StoreChan) error {
	lst, err := s.List()
	if err != nil {
		return fmt.Errorf("Error listing user: %s\n", err)
	}

	var keys []string
	for k := range lst {
		keys = append(keys, k)
	}
	sort.Strings(keys)

	table := uitable.New()
	table.MaxColWidth = 50
	table.AddRow("NAME", "TYPE", "LAST-CHANGED")
	for _, k := range keys {
		t := "user"
		if lst[k].IsAdmin {
			t = "admin"
		}
		table.AddRow(k, t, lst[k].LastChanged.String())
	}
	fmt.Println(table)
	return nil
}
開發者ID:whawty,項目名稱:auth,代碼行數:25,代碼來源:main.go

示例5: execQueueCommand

// Executes the "queue" command
func execQueueCommand(c *cli.Context) {
	if len(c.Args()) == 0 {
		displayError(errMissingMinion, 64)
	}

	minion := uuid.Parse(c.Args()[0])
	if minion == nil {
		displayError(errInvalidUUID, 64)
	}

	client := newEtcdMinionClientFromFlags(c)

	// Ignore errors about missing queue directory
	queue, err := client.MinionTaskQueue(minion)
	if err != nil {
		if eerr, ok := err.(etcdclient.Error); !ok || eerr.Code != etcdclient.ErrorCodeKeyNotFound {
			displayError(err, 1)
		}
	}

	if len(queue) == 0 {
		return
	}

	table := uitable.New()
	table.MaxColWidth = 40
	table.AddRow("TASK", "COMMAND", "STATE", "TIME")
	for _, task := range queue {
		table.AddRow(task.TaskID, task.Command, task.State, time.Unix(task.TimeReceived, 0))
	}

	fmt.Println(table)
}
開發者ID:leobcn,項目名稱:gru,代碼行數:34,代碼來源:queue_command.go

示例6: execQueueCommand

// Executes the "queue" command
func execQueueCommand(c *cli.Context) error {
	if len(c.Args()) == 0 {
		return cli.NewExitError(errNoMinion.Error(), 64)
	}

	minion := uuid.Parse(c.Args()[0])
	if minion == nil {
		return cli.NewExitError(errInvalidUUID.Error(), 64)
	}

	klient := newEtcdMinionClientFromFlags(c)

	// Ignore errors about missing queue directory
	queue, err := klient.MinionTaskQueue(minion)
	if err != nil {
		if eerr, ok := err.(client.Error); !ok || eerr.Code != client.ErrorCodeKeyNotFound {
			return cli.NewExitError(err.Error(), 1)
		}
	}

	if len(queue) == 0 {
		return nil
	}

	table := uitable.New()
	table.MaxColWidth = 40
	table.AddRow("TASK", "STATE", "RECEIVED")
	for _, t := range queue {
		table.AddRow(t.ID, t.State, time.Unix(t.TimeReceived, 0))
	}

	fmt.Println(table)

	return nil
}
開發者ID:dnaeon,項目名稱:gru,代碼行數:36,代碼來源:queue.go

示例7: execInfoCommand

// Executes the "info" command
func execInfoCommand(c *cli.Context) error {
	if len(c.Args()) == 0 {
		return cli.NewExitError(errNoMinion.Error(), 64)
	}

	arg := c.Args()[0]
	minion := uuid.Parse(arg)
	if minion == nil {
		return cli.NewExitError(errInvalidUUID.Error(), 64)
	}

	klient := newEtcdMinionClientFromFlags(c)
	name, err := klient.MinionName(minion)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}

	lastseen, err := klient.MinionLastseen(minion)
	if err != nil {
		return cli.NewExitError(err.Error(), 1)
	}

	// Ignore errors about missing queue directory
	taskQueue, err := klient.MinionTaskQueue(minion)
	if err != nil {
		if eerr, ok := err.(client.Error); !ok || eerr.Code != client.ErrorCodeKeyNotFound {
			return cli.NewExitError(err.Error(), 1)
		}
	}

	// Ignore errors about missing log directory
	taskLog, err := klient.MinionTaskLog(minion)
	if err != nil {
		if eerr, ok := err.(client.Error); !ok || eerr.Code != client.ErrorCodeKeyNotFound {
			return cli.NewExitError(err.Error(), 1)
		}
	}

	// Ignore errors about missing classifier directory
	classifierKeys, err := klient.MinionClassifierKeys(minion)
	if err != nil {
		if eerr, ok := err.(client.Error); !ok || eerr.Code != client.ErrorCodeKeyNotFound {
			return cli.NewExitError(err.Error(), 1)
		}
	}

	table := uitable.New()
	table.MaxColWidth = 80
	table.AddRow("Minion:", minion)
	table.AddRow("Name:", name)
	table.AddRow("Lastseen:", time.Unix(lastseen, 0))
	table.AddRow("Queue:", len(taskQueue))
	table.AddRow("Log:", len(taskLog))
	table.AddRow("Classifiers:", len(classifierKeys))

	fmt.Println(table)

	return nil
}
開發者ID:dnaeon,項目名稱:gru,代碼行數:60,代碼來源:info.go

示例8: displayMap

func displayMap(writer io.Writer, props map[string]interface{}) {
	table := uitable.New()
	for key, value := range props {
		table.AddRow("", labelUI(key), value)
	}
	fmt.Fprintln(writer, table)
	fmt.Fprintln(writer)
}
開發者ID:hackliff,項目名稱:unlog,代碼行數:8,代碼來源:ui.go

示例9: Build

// Print out the steps inline.
func Build() string {
	table := uitable.New()
	table.MaxColWidth = 50
	for _, s := range steps {
		table.AddRow(s, s.Complete)
	}
	return table.String()
}
開發者ID:nickschuch,項目名稱:steps,代碼行數:9,代碼來源:steps.go

示例10: printRequirements

// printRequirements prints all of the requirements in the yaml file.
func (l *dependencyListCmd) printRequirements(reqs *chartutil.Requirements, out io.Writer) {
	table := uitable.New()
	table.MaxColWidth = 80
	table.AddRow("NAME", "VERSION", "REPOSITORY", "STATUS")
	for _, row := range reqs.Dependencies {
		table.AddRow(row.Name, row.Version, row.Repository, l.dependencyStatus(row))
	}
	fmt.Fprintln(out, table)
}
開發者ID:technosophos,項目名稱:k8s-helm,代碼行數:10,代碼來源:dependency.go

示例11: repaint

func repaint(w *uilive.Writer, logCounters []*LogCounter, totalLinesRead int) {
	table := uitable.New()
	table.AddRow("PATTERN", "COUNT", "RATE/s", "RATE/m", "RATE/hr")
	for _, c := range logCounters {
		table.AddRow(c.p.String(), c.c.Value(), c.rsec.String(), c.rmin.String(), c.rhr.String())
	}

	table.AddRow("Total Lines Read:", totalLinesRead, "--", "--", "--")
	fmt.Fprintln(w, table)
	w.Flush()
}
開發者ID:nickcarenza,項目名稱:logcounter,代碼行數:11,代碼來源:main.go

示例12: formatSearchResults

func (s *searchCmd) formatSearchResults(res []*search.Result) string {
	if len(res) == 0 {
		return "No results found"
	}
	table := uitable.New()
	table.MaxColWidth = 50
	table.AddRow("NAME", "VERSION", "DESCRIPTION")
	for _, r := range res {
		table.AddRow(r.Name, r.Chart.Version, r.Chart.Description)
	}
	return table.String()
}
開發者ID:technosophos,項目名稱:k8s-helm,代碼行數:12,代碼來源:search.go

示例13: ToPlainTextSummary

// ToPlainTextSummary format summary for plain text.
func ToPlainTextSummary(r models.ScanResult) string {
	stable := uitable.New()
	stable.MaxColWidth = 84
	stable.Wrap = true

	cves := r.KnownCves
	if !config.Conf.IgnoreUnscoredCves {
		cves = append(cves, r.UnknownCves...)
	}

	for _, d := range cves {
		var scols []string

		switch {
		case config.Conf.Lang == "ja" &&
			0 < d.CveDetail.Jvn.CvssScore():

			summary := d.CveDetail.Jvn.CveTitle()
			scols = []string{
				d.CveDetail.CveID,
				fmt.Sprintf("%-4.1f (%s)",
					d.CveDetail.CvssScore(config.Conf.Lang),
					d.CveDetail.Jvn.CvssSeverity(),
				),
				summary,
			}
		case 0 < d.CveDetail.CvssScore("en"):
			summary := d.CveDetail.Nvd.CveSummary()
			scols = []string{
				d.CveDetail.CveID,
				fmt.Sprintf("%-4.1f (%s)",
					d.CveDetail.CvssScore(config.Conf.Lang),
					d.CveDetail.Nvd.CvssSeverity(),
				),
				summary,
			}
		default:
			scols = []string{
				d.CveDetail.CveID,
				"?",
				d.CveDetail.Nvd.CveSummary(),
			}
		}

		cols := make([]interface{}, len(scols))
		for i := range cols {
			cols[i] = scols[i]
		}
		stable.AddRow(cols...)
	}
	return fmt.Sprintf("%s", stable)
}
開發者ID:Rompei,項目名稱:vuls,代碼行數:53,代碼來源:util.go

示例14: formatList

func formatList(rels []*release.Release) string {
	table := uitable.New()
	table.MaxColWidth = 30
	table.AddRow("NAME", "REVISION", "UPDATED", "STATUS", "CHART")
	for _, r := range rels {
		c := fmt.Sprintf("%s-%s", r.Chart.Metadata.Name, r.Chart.Metadata.Version)
		t := timeconv.String(r.Info.LastDeployed)
		s := r.Info.Status.Code.String()
		v := r.Version
		table.AddRow(r.Name, v, t, s, c)
	}
	return table.String()
}
開發者ID:slack,項目名稱:helm,代碼行數:13,代碼來源:list.go

示例15: formatTabular

func formatTabular(metrics ...metric) string {
	table := uitable.New()
	table.MaxColWidth = 50
	table.Wrap = true
	for _, col := range []int{1, 2, 3, 4} {
		table.RightAlign(col)
	}
	table.AddRow("UNIT", "TIMESTAMP", "METRIC", "VALUE")
	for _, m := range metrics {
		table.AddRow(m.Unit, m.Timestamp.Format(time.RFC3339), m.Metric, m.Value)
	}
	return table.String() + "\n"
}
開發者ID:bac,項目名稱:juju,代碼行數:13,代碼來源:cmd_juju_metrics.go


注:本文中的github.com/gosuri/uitable.New函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。