commands

package
v0.0.0-...-f734b3f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SearchCommand = cli.Command{
	Name:        "search",
	Usage:       "search <arguments>",
	Description: "Searches for flakes",

	Flags: []cli.Flag{
		cli.IntFlag{
			Name:  "limit, l",
			Usage: "Limit number of builds to check",
			Value: 50,
		},
		cli.StringFlag{
			Name:  "job, j",
			Usage: "Job name to search",
			Value: "",
		},
	},

	Action: func(ctx *cli.Context) error {
		if ctx.Args().First() == "" {
			return cli.NewExitError("need to provide a pattern", 1)
		}

		client := ctx.App.Metadata["client"].(fly.Client)

		searcher := hunter.NewSearcher(client)
		spec := hunter.SearchSpec{
			Pattern: ctx.Args().First(),
			Limit:   ctx.Int("limit"),
			Job:     ctx.String("job"),
		}
		builds, err := searcher.Search(spec)
		if err != nil {
			return cli.NewExitError(err.Error(), 1)
		}

		table := &Table{
			Content: [][]string{},
			Header:  []string{"pipeline/job", "build url"},
		}

		for _, build := range builds {
			line := []string{}
			line = append(line, fmt.Sprintf("%s/%s", build.PipelineName, build.JobName))
			line = append(line, fmt.Sprintf("%s", build.ConcourseURL))
			table.Content = append(table.Content, line)
		}

		context := &Context{Stdout: os.Stdout}
		table.Render(context)
		return nil
	},
}

Functions

This section is empty.

Types

type Context

type Context struct {
	cli.Context
	Stdout io.Writer
}

type Table

type Table struct {
	Content [][]string
	Header  []string
}

func (*Table) Render

func (t *Table) Render(context *Context)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL