本文整理汇总了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
}
示例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
}
示例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
}
示例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
}
示例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)
}
示例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
}
示例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
}
示例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)
}
示例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()
}
示例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)
}
示例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()
}
示例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()
}
示例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)
}
示例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()
}
示例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"
}