github.com/bshelton229/agent@v3.5.4+incompatible/main.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "os" 6 7 "github.com/buildkite/agent/agent" 8 "github.com/buildkite/agent/clicommand" 9 "github.com/urfave/cli" 10 ) 11 12 var AppHelpTemplate = `Usage: 13 14 {{.Name}} <command> [arguments...] 15 16 Available commands are: 17 18 {{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}} 19 {{end}} 20 Use "{{.Name}} <command> --help" for more information about a command. 21 22 ` 23 24 var SubcommandHelpTemplate = `Usage: 25 26 {{.Name}} {{if .VisibleFlags}}<command>{{end}} [arguments...] 27 28 Available commands are: 29 30 {{range .Commands}}{{.Name}}{{with .ShortName}}, {{.}}{{end}}{{ "\t" }}{{.Usage}} 31 {{end}}{{if .VisibleFlags}} 32 Options: 33 34 {{range .VisibleFlags}}{{.}} 35 {{end}}{{end}} 36 ` 37 38 var CommandHelpTemplate = `{{.Description}} 39 40 Options: 41 42 {{range .VisibleFlags}}{{.}} 43 {{end}} 44 ` 45 46 func printVersion(c *cli.Context) { 47 fmt.Printf("%v version %v, build %v\n", c.App.Name, c.App.Version, agent.BuildVersion()) 48 } 49 50 func main() { 51 cli.AppHelpTemplate = AppHelpTemplate 52 cli.CommandHelpTemplate = CommandHelpTemplate 53 cli.SubcommandHelpTemplate = SubcommandHelpTemplate 54 cli.VersionPrinter = printVersion 55 56 app := cli.NewApp() 57 app.Name = "buildkite-agent" 58 app.Version = agent.Version() 59 app.Commands = []cli.Command{ 60 clicommand.AgentStartCommand, 61 clicommand.AnnotateCommand, 62 { 63 Name: "artifact", 64 Usage: "Upload/download artifacts from Buildkite jobs", 65 Subcommands: []cli.Command{ 66 clicommand.ArtifactUploadCommand, 67 clicommand.ArtifactDownloadCommand, 68 clicommand.ArtifactShasumCommand, 69 }, 70 }, 71 { 72 Name: "meta-data", 73 Usage: "Get/set data from Buildkite jobs", 74 Subcommands: []cli.Command{ 75 clicommand.MetaDataSetCommand, 76 clicommand.MetaDataGetCommand, 77 clicommand.MetaDataExistsCommand, 78 }, 79 }, 80 { 81 Name: "pipeline", 82 Usage: "Make changes to the pipeline of the currently running build", 83 Subcommands: []cli.Command{ 84 clicommand.PipelineUploadCommand, 85 }, 86 }, 87 clicommand.BootstrapCommand, 88 } 89 90 // When no sub command is used 91 app.Action = func(c *cli.Context) { 92 cli.ShowAppHelp(c) 93 os.Exit(1) 94 } 95 96 // When a sub command can't be found 97 app.CommandNotFound = func(c *cli.Context, command string) { 98 cli.ShowAppHelp(c) 99 os.Exit(1) 100 } 101 102 if err := app.Run(os.Args); err != nil { 103 fmt.Printf("%v\n", err) 104 os.Exit(1) 105 } 106 }