Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: client/cmd/buildbucket/get.go

Issue 2227113002: Update bulidbucket client (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « client/cmd/buildbucket/cancel.go ('k') | client/cmd/buildbucket/main.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
5 package main
6
7 import (
8 "fmt"
9 "strconv"
10
11 "github.com/maruel/subcommands"
12
13 "github.com/luci/luci-go/common/cli"
14 "github.com/luci/luci-go/common/logging"
15 )
16
17 var cmdGet = &subcommands.Command{
18 UsageLine: `get [flags] <build id>`,
19 ShortDesc: "get details about a build",
20 LongDesc: "Get details about a build.",
21 CommandRun: func() subcommands.CommandRun {
22 c := &getRun{}
23 c.SetDefaultFlags()
24 return c
25 },
26 }
27
28 type getRun struct {
29 baseCommandRun
30 }
31
32 func (r *getRun) Run(a subcommands.Application, args []string) int {
33 ctx := cli.GetContext(a, r)
34 if len(args) < 1 {
35 logging.Errorf(ctx, "missing parameter: <Build ID>")
36 return 1
37 } else if len(args) > 1 {
38 logging.Errorf(ctx, "unexpected arguments: %s", args[1:])
39 }
40
41 buildId, err := strconv.ParseInt(args[0], 10, 64)
42 if err != nil {
43 logging.Errorf(ctx, "expected a build id (int64): %s", err)
44 return 1
45 }
46
47 service, err := r.makeService(ctx, a)
48 if err != nil {
49 return 1
50 }
51
52 response, err := service.Get(buildId).Do()
53 if err != nil {
54 logging.Errorf(ctx, "buildbucket.Get failed: %s", err)
55 return 1
56 }
57
58 responseJSON, err := response.MarshalJSON()
59 if err != nil {
60 logging.Errorf(ctx, "could not unmarshal response: %s", err)
61 return 1
62 }
63 fmt.Println(string(responseJSON))
64 return 0
65 }
OLDNEW
« no previous file with comments | « client/cmd/buildbucket/cancel.go ('k') | client/cmd/buildbucket/main.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698