Skip to content

Commit

Permalink
Add feature to autofix the checksum
Browse files Browse the repository at this point in the history
Signed-off-by: Ali Yousuf <aly.yousuf7@gmail.com>
  • Loading branch information
alyyousuf7 committed Sep 22, 2020
1 parent 09d76af commit 5a1fe78
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cli/imei/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ func main() {
var inputFile string
flag.StringVar(&inputFile, "input", "-", "input `path` (use - for stdin)")

var autofix bool
flag.BoolVar(&autofix, "autofix", true, "autofix the hexadecimal checksum")

flag.Parse()

var outputFormat imei.IMEIFormat
Expand Down Expand Up @@ -73,6 +76,9 @@ func main() {
parsedIMEI, err = imei.HexadecimalIMEI.Parse(text)
if err != nil {
parsedIMEI, err = imei.HexadecimalChecksumIMEI.Parse(text)
if err != nil && autofix {
parsedIMEI, err = imei.HexadecimalIMEI.Parse(text[:len(text)-1])
}
}
}
case "dec":
Expand Down

0 comments on commit 5a1fe78

Please sign in to comment.