Skip to content

Commit

Permalink
feat(tooling): migrate kythe CLI to new filetree API (#3487)
Browse files Browse the repository at this point in the history
  • Loading branch information
schroederc committed Feb 14, 2019
1 parent 15e4412 commit 59aee1e
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions kythe/go/services/cli/command_ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,27 +121,20 @@ func (c lsCommand) displayDirectory(d *ftpb.DirectoryReply) error {
return PrintJSONMessage(d)
}

for _, d := range d.Subdirectory {
if !c.lsURIs {
uri, err := kytheuri.Parse(d)
if err != nil {
return fmt.Errorf("received invalid directory uri %q: %v", d, err)
}
d = filepath.Base(uri.Path) + "/"
}
if _, err := fmt.Fprintln(out, d); err != nil {
return err
}
}
for _, f := range d.File {
if !c.lsURIs {
uri, err := kytheuri.Parse(f)
if err != nil {
return fmt.Errorf("received invalid file ticket %q: %v", f, err)
for _, e := range d.Entry {
name := e.Name
if c.lsURIs {
uri := &kytheuri.URI{
Corpus: d.Corpus,
Root: d.Root,
Path: filepath.Join(d.Path, name),
}
f = filepath.Base(uri.Path)
name = uri.String()
} else if e.Kind == ftpb.DirectoryReply_DIRECTORY {
name += "/"
}
if _, err := fmt.Fprintln(out, f); err != nil {

if _, err := fmt.Fprintln(out, name); err != nil {
return err
}
}
Expand Down

0 comments on commit 59aee1e

Please sign in to comment.