1
0
Fork 0

Ignore empty change type or index in command line parameters

This commit is contained in:
Michał Rudowicz 2024-02-18 19:19:10 +01:00
parent 23004084b4
commit 9360d89fe1
1 changed files with 6 additions and 0 deletions

View File

@ -91,6 +91,9 @@ func getCmdLineParams(logger *log.Logger) (string, []int64, []satel.ChangeType,
allowedTypesStrings := strings.Split(*allowedTypesRaw, ",") allowedTypesStrings := strings.Split(*allowedTypesRaw, ",")
var allowedTypes []satel.ChangeType var allowedTypes []satel.ChangeType
for _, allowedTypeStr := range allowedTypesStrings { for _, allowedTypeStr := range allowedTypesStrings {
if len(allowedTypeStr) == 0 {
continue
}
allowedType, err := StringToSatelChangeType(allowedTypeStr) allowedType, err := StringToSatelChangeType(allowedTypeStr)
if err != nil { if err != nil {
logger.Fatalf("Error trying to understand an allowed type: %s.", err) logger.Fatalf("Error trying to understand an allowed type: %s.", err)
@ -100,6 +103,9 @@ func getCmdLineParams(logger *log.Logger) (string, []int64, []satel.ChangeType,
allowedIndexesStrings := strings.Split(*allowedIndexesRaw, ",") allowedIndexesStrings := strings.Split(*allowedIndexesRaw, ",")
var allowedIndexes []int var allowedIndexes []int
for _, allowedIndexStr := range allowedIndexesStrings { for _, allowedIndexStr := range allowedIndexesStrings {
if len(allowedIndexStr) == 0 {
continue
}
allowedIndex, err := strconv.ParseInt(allowedIndexStr, 10, 0) allowedIndex, err := strconv.ParseInt(allowedIndexStr, 10, 0)
if err != nil { if err != nil {
logger.Fatalf("Tried to use a non-int value for one of allowed indexes: %s. That's bad.", allowedIndexStr) logger.Fatalf("Tried to use a non-int value for one of allowed indexes: %s. That's bad.", allowedIndexStr)