Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add list and filter commands #227

Merged
merged 4 commits into from
Sep 10, 2021
Merged

Add list and filter commands #227

merged 4 commits into from
Sep 10, 2021

Conversation

willscott
Copy link
Member

example usage:

car list test.car | head -n 50 | car filter test.car trimmed.car

}
return err
}
outStream.WriteString(fmt.Sprintf("%s\n", blk.Cid()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
outStream.WriteString(fmt.Sprintf("%s\n", blk.Cid()))
fmt.Fprintf(outStream, "%s\n", blk.Cid())

}
defer outStream.Close()

rd, err := icarv1.NewCarReader(r.DataReader())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use https://pkg.go.dev/github.com/ipld/go-car/v2@master#BlockReader? it was written precisely for this :) and it even supports both carv1 and carv2.

}
fmt.Printf("filtering to %d cids\n", len(cidList))

cidMap := make(map[cid.Cid]struct{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider making parseCIDs build a map directly

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also I wonder if you should at least print a warning on duplicate CIDs

@willscott willscott merged commit afcc7b3 into master Sep 10, 2021
@willscott willscott deleted the carve branch September 10, 2021 09:17
@aschmahmann aschmahmann mentioned this pull request Dec 1, 2021
80 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants