MCPcopy
hub / github.com/perkeep/perkeep / RunCommand

Method RunCommand

cmd/pk/describe.go:61–98  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

59}
60
61func (c *desCmd) RunCommand(args []string) error {
62 if len(args) == 0 {
63 return cmdmain.UsageError("requires blobref")
64 }
65 var blobs []blob.Ref
66 for _, arg := range args {
67 br, ok := blob.Parse(arg)
68 if !ok {
69 return cmdmain.UsageError(fmt.Sprintf("invalid blobref %q", arg))
70 }
71 blobs = append(blobs, br)
72 }
73 var at time.Time // TODO: add "2 days ago" "-2d", "-2h", "2013-02-05", etc
74 if c.at != "" {
75 var err error
76 at, err = time.Parse(time.RFC3339, c.at)
77 if err != nil {
78 return fmt.Errorf("error parsing --at value %q: %v", c.at, err)
79 }
80 }
81
82 cl := newClient(c.server)
83 res, err := cl.Describe(context.Background(), &search.DescribeRequest{
84 BlobRefs: blobs,
85 Depth: c.depth,
86 At: types.Time3339(at),
87 })
88 if err != nil {
89 return err
90 }
91 resj, err := json.MarshalIndent(res, "", " ")
92 if err != nil {
93 return err
94 }
95 resj = append(resj, '\n')
96 _, err = os.Stdout.Write(resj)
97 return err
98}

Callers

nothing calls this directly

Calls 6

UsageErrorTypeAlias · 0.92
ParseFunction · 0.92
ParseMethod · 0.80
newClientFunction · 0.70
DescribeMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected