go_subnetter/cmd/subnetter/funcs_vlsmargs.go
brent saner d37aa3eb6b
v0.1.1
ADDED:
* The -s/--size argument to the VLSM splitter may now be a
  comma-delimited list of sizes instead of needing to specify -s/--size
  for each size.
  This change is backwards-compatible.
2025-04-04 11:53:55 -04:00

27 lines
498 B
Go

package main
/*
AllSizes returns a properly parsed and consolidated slice
of all specified sizes, as it takes two valid syntaxes (`-s 32 -s 32`, `-s 32,32`)
that can be mixed together.
*/
func (v *VLSMArgs) AllSizes() (sizes []uint8, err error) {
var sizeSlice []uint8
if v == nil {
return
}
if v.Sizes == nil || len(v.Sizes) == 0 {
return
}
for _, s := range v.Sizes {
if sizeSlice, err = s.Sizes(); err != nil {
return
}
sizes = append(sizes, sizeSlice...)
}
return
}