| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package cli | 5 package cli |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bufio" | 8 "bufio" |
| 9 "fmt" | 9 "fmt" |
| 10 "os" | 10 "os" |
| 11 "sort" | 11 "sort" |
| 12 "strings" | 12 "strings" |
| 13 | 13 |
| 14 "github.com/luci/luci-go/common/errors" |
| 14 log "github.com/luci/luci-go/common/logging" | 15 log "github.com/luci/luci-go/common/logging" |
| 15 "github.com/luci/luci-go/common/proto/google" | 16 "github.com/luci/luci-go/common/proto/google" |
| 16 "github.com/luci/luci-go/logdog/client/coordinator" | 17 "github.com/luci/luci-go/logdog/client/coordinator" |
| 17 "github.com/luci/luci-go/logdog/common/types" | 18 "github.com/luci/luci-go/logdog/common/types" |
| 18 "github.com/luci/luci-go/luci_config/common/cfgtypes" | 19 "github.com/luci/luci-go/luci_config/common/cfgtypes" |
| 19 | 20 |
| 20 "github.com/maruel/subcommands" | 21 "github.com/maruel/subcommands" |
| 21 ) | 22 ) |
| 22 | 23 |
| 23 const ( | 24 const ( |
| (...skipping 26 matching lines...) Expand all Loading... |
| 50 func (cmd *listCommandRun) Run(scApp subcommands.Application, args []string, _ s
ubcommands.Env) int { | 51 func (cmd *listCommandRun) Run(scApp subcommands.Application, args []string, _ s
ubcommands.Env) int { |
| 51 a := scApp.(*application) | 52 a := scApp.(*application) |
| 52 | 53 |
| 53 if len(args) == 0 { | 54 if len(args) == 0 { |
| 54 args = []string{""} | 55 args = []string{""} |
| 55 } | 56 } |
| 56 | 57 |
| 57 bio := bufio.NewWriter(os.Stdout) | 58 bio := bufio.NewWriter(os.Stdout) |
| 58 defer bio.Flush() | 59 defer bio.Flush() |
| 59 | 60 |
| 61 coord, err := a.coordinatorClient("") |
| 62 if err != nil { |
| 63 errors.Log(a, errors.Annotate(err).Reason("could not create Coor
dinator client").Err()) |
| 64 return 1 |
| 65 } |
| 66 |
| 60 for _, arg := range args { | 67 for _, arg := range args { |
| 61 arg = strings.TrimSpace(arg) | 68 arg = strings.TrimSpace(arg) |
| 62 | 69 |
| 63 var ( | 70 var ( |
| 64 project cfgtypes.ProjectName | 71 project cfgtypes.ProjectName |
| 65 pathBase string | 72 pathBase string |
| 66 unified bool | 73 unified bool |
| 67 ) | 74 ) |
| 68 if len(arg) > 0 { | 75 if len(arg) > 0 { |
| 69 // User-friendly: trim any leading or trailing slashes f
rom the path. | 76 // User-friendly: trim any leading or trailing slashes f
rom the path. |
| 70 var err error | 77 var err error |
| 71 project, pathBase, unified, err = a.splitPath(string(typ
es.StreamPath(arg).Trim())) | 78 project, pathBase, unified, err = a.splitPath(string(typ
es.StreamPath(arg).Trim())) |
| 72 if err != nil { | 79 if err != nil { |
| 73 log.WithError(err).Errorf(a, "Invalid path speci
fier.") | 80 log.WithError(err).Errorf(a, "Invalid path speci
fier.") |
| 74 return 1 | 81 return 1 |
| 75 } | 82 } |
| 76 } | 83 } |
| 77 | 84 |
| 78 » » err := a.coord.List(a, project, pathBase, cmd.o, func(lr *coordi
nator.ListResult) bool { | 85 » » err := coord.List(a, project, pathBase, cmd.o, func(lr *coordina
tor.ListResult) bool { |
| 79 p := lr.Name | 86 p := lr.Name |
| 80 if cmd.o.State { | 87 if cmd.o.State { |
| 81 // Long listing, show full path. | 88 // Long listing, show full path. |
| 82 fp := lr.FullPath() | 89 fp := lr.FullPath() |
| 83 if unified { | 90 if unified { |
| 84 p = makeUnifiedPath(lr.Project, fp) | 91 p = makeUnifiedPath(lr.Project, fp) |
| 85 } else { | 92 } else { |
| 86 p = string(fp) | 93 p = string(fp) |
| 87 } | 94 } |
| 88 } | 95 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 parts = append(parts, "archived") | 147 parts = append(parts, "archived") |
| 141 } | 148 } |
| 142 | 149 |
| 143 if s.State.Purged { | 150 if s.State.Purged { |
| 144 parts = append(parts, "purged") | 151 parts = append(parts, "purged") |
| 145 } | 152 } |
| 146 } | 153 } |
| 147 | 154 |
| 148 return strings.Join(parts, " ") | 155 return strings.Join(parts, " ") |
| 149 } | 156 } |
| OLD | NEW |