Skip to content

Commit

Permalink
chore: add a length indicator to the prefix length
Browse files Browse the repository at this point in the history
  • Loading branch information
bschaatsbergen committed Dec 9, 2023
1 parent cb58113 commit f9dce3a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/explain.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ func getNetworkDetails(network *net.IPNet) *networkDetailsToDisplay {

//nolint:goconst
func explain(details *networkDetailsToDisplay) {
var lengthIndicator string

fmt.Printf(color.BlueString("Base Address:\t\t ")+"%s\n", details.BaseAddress)
if !details.UsableAddressRangeHasError {
fmt.Printf(color.BlueString("Usable Address Range:\t ")+"%s to %s\n", details.FirstUsableIPAddress, details.LastUsableIPAddress)
Expand All @@ -120,5 +122,12 @@ func explain(details *networkDetailsToDisplay) {
fmt.Printf(color.RedString("Broadcast Address:\t ")+"%s\n", details.BroadcastAddress)
}
fmt.Printf(color.BlueString("Address Count:\t\t ")+"%s\n", details.Count)
fmt.Printf(color.BlueString("Netmask:\t\t ")+"%s (/%d bits)\n", details.Netmask, details.PrefixLength)

if details.PrefixLength > 1 {
lengthIndicator = "bits"
} else {
lengthIndicator = "bit"
}

fmt.Printf(color.BlueString("Netmask:\t\t ")+"%s (/%d %s)\n", details.Netmask, details.PrefixLength, lengthIndicator)
}

0 comments on commit f9dce3a

Please sign in to comment.