本文整理汇总了Golang中github.com/gosuri/uitable.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: toOneLineSummary
func toOneLineSummary(rs ...models.ScanResult) string {
table := uitable.New()
table.MaxColWidth = maxColWidth
table.Wrap = true
for _, r := range rs {
cols := []interface{}{
r.FormatServerName(),
r.CveSummary(),
r.Packages.ToUpdatablePacksSummary(),
}
table.AddRow(cols...)
}
return fmt.Sprintf("%s\n", table)
}
开发者ID:ymomoi,项目名称:vuls,代码行数:14,代码来源:util.go
示例17: formatHistory
func formatHistory(rls []*release.Release) string {
tbl := uitable.New()
tbl.MaxColWidth = 30
tbl.AddRow("REVISION", "UPDATED", "STATUS", "CHART")
for i := len(rls) - 1; i >= 0; i-- {
r := rls[i]
c := formatChartname(r.Chart)
t := timeconv.String(r.Info.LastDeployed)
s := r.Info.Status.Code.String()
v := r.Version
tbl.AddRow(v, t, s, c)
}
return tbl.String()
}
开发者ID:technosophos,项目名称:k8s-helm,代码行数:14,代码来源:history.go
示例18: Example
func Example() {
table := uitable.New()
table.MaxColWidth = 50
fmt.Println("==> List")
table.AddRow("NAME", "BIRTHDAY", "BIO")
for _, hacker := range hackers {
table.AddRow(hacker.Name, hacker.Birthday, hacker.Bio)
}
fmt.Println(table)
fmt.Print("\n==> Details\n")
table = uitable.New()
table.MaxColWidth = 80
table.Wrap = true
for _, hacker := range hackers {
table.AddRow("Name:", hacker.Name)
table.AddRow("Birthday:", hacker.Birthday)
table.AddRow("Bio:", hacker.Bio)
table.AddRow("") // blank
}
fmt.Println(table)
}
开发者ID:nickschuch,项目名称:kube-haproxy,代码行数:23,代码来源:example_test.go
示例19: toScanSummary
func toScanSummary(rs ...models.ScanResult) string {
table := uitable.New()
table.MaxColWidth = maxColWidth
table.Wrap = true
for _, r := range rs {
cols := []interface{}{
r.FormatServerName(),
fmt.Sprintf("%s%s", r.Family, r.Release),
fmt.Sprintf("%d CVEs", len(r.ScannedCves)),
r.Packages.ToUpdatablePacksSummary(),
}
table.AddRow(cols...)
}
return fmt.Sprintf("%s\n", table)
}
开发者ID:ymomoi,项目名称:vuls,代码行数:15,代码来源:util.go
示例20: runRepoList
func runRepoList(cmd *cobra.Command, args []string) error {
f, err := repo.LoadRepositoriesFile(repositoriesFile())
if err != nil {
return err
}
if len(f.Repositories) == 0 {
return errors.New("no repositories to show")
}
table := uitable.New()
table.MaxColWidth = 50
table.AddRow("NAME", "URL")
for k, v := range f.Repositories {
table.AddRow(k, v)
}
fmt.Println(table)
return nil
}
开发者ID:Chronojam,项目名称:helm,代码行数:17,代码来源:repo.go
注:本文中的github.com/gosuri/uitable.New函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论