Skip to content

Commit

Permalink
fix!: use -version=n instead of -v1 for index command
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed Oct 22, 2021
1 parent 182d3a9 commit 7e59d53
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 4 additions & 3 deletions cmd/car/car.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ func main1() int {
Usage: "The type of index to write",
Value: multicodec.CarMultihashIndexSorted.String(),
},
&cli.BoolFlag{
Name: "v1",
Usage: "Write out only the carV1 file. Implies codec of 'none'",
&cli.IntFlag{
Name: "version",
Value: 2,
Usage: "Write output as a v1 or v2 format car",
},
},
},
Expand Down
8 changes: 6 additions & 2 deletions cmd/car/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ func IndexCar(c *cli.Context) error {
}
defer r.Close()

if c.Bool("v1") {
if c.Int("version") == 1 {
if c.IsSet("codec") && c.String("codec") != "none" {
return fmt.Errorf("only supported codec for a v1 car is 'none'")
return fmt.Errorf("'none' is the only supported codec for a v1 car")
}
outStream := os.Stdout
if c.Args().Len() >= 2 {
Expand All @@ -40,6 +40,10 @@ func IndexCar(c *cli.Context) error {
return err
}

if c.Int("version") != 2 {
return fmt.Errorf("invalid CAR version %d", c.Int("version"))
}

var idx index.Index
if c.String("codec") != "none" {
var mc multicodec.Code
Expand Down

0 comments on commit 7e59d53

Please sign in to comment.