add bitfield merge func
This commit is contained in:
parent
a7ed639c21
commit
253e22d6ea
@ -27,10 +27,11 @@ var bitFieldCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Subcommands: []*cli.Command{
|
Subcommands: []*cli.Command{
|
||||||
bitFieldRunsCmd,
|
|
||||||
bitFieldStatCmd,
|
|
||||||
bitFieldEncodeCmd,
|
bitFieldEncodeCmd,
|
||||||
bitFieldDecodeCmd,
|
bitFieldDecodeCmd,
|
||||||
|
bitFieldRunsCmd,
|
||||||
|
bitFieldStatCmd,
|
||||||
|
bitFieldMergeCmd,
|
||||||
bitFieldIntersectCmd,
|
bitFieldIntersectCmd,
|
||||||
bitFieldSubCmd,
|
bitFieldSubCmd,
|
||||||
},
|
},
|
||||||
@ -152,6 +153,36 @@ var bitFieldDecodeCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var bitFieldMergeCmd = &cli.Command{
|
||||||
|
Name: "merge",
|
||||||
|
Usage: "Merge 2 bitfields",
|
||||||
|
Description: "Merge 2 bitfields and print the resulting bitfield",
|
||||||
|
Action: func(cctx *cli.Context) error {
|
||||||
|
a, err := decode(cctx, 0)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
b, err := decode(cctx, 1)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
o, err := bitfield.MergeBitFields(a, b)
|
||||||
|
if err != nil {
|
||||||
|
return xerrors.Errorf("merge: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
str, err := encode(cctx, o)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
fmt.Println(str)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
var bitFieldIntersectCmd = &cli.Command{
|
var bitFieldIntersectCmd = &cli.Command{
|
||||||
Name: "intersect",
|
Name: "intersect",
|
||||||
Usage: "Intersect 2 bitfields",
|
Usage: "Intersect 2 bitfields",
|
||||||
|
Loading…
Reference in New Issue
Block a user