From a95eab3221d1d5571bfb2e5eab106fd20ab7237f Mon Sep 17 00:00:00 2001 From: lauralani Date: Fri, 24 Mar 2023 17:59:51 +0100 Subject: [PATCH] made subnet list output prettier --- cmd/subnet-list.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cmd/subnet-list.go b/cmd/subnet-list.go index 46999f2..b68d852 100644 --- a/cmd/subnet-list.go +++ b/cmd/subnet-list.go @@ -39,8 +39,9 @@ var subnetlistCmd = &cobra.Command{ return subnets[i].Subnet.Addr().Less(subnets[j].Subnet.Addr()) }) + fmt.Printf("%-15s VLAN %-25s Free IPs\n", "Prefix", "Name") + for _, subnet := range subnets { - //if verbose { var numip, freeip int if subnet.Subnet.Addr().Is4() { @@ -53,9 +54,16 @@ var subnetlistCmd = &cobra.Command{ freeip = numip - len(subnet.Addresses) - fmt.Printf("%v:\t%v\t(vl: %v)\tfree: %v\n", subnet.Subnet, subnet.Name, subnet.Vlan, freeip) + if freeip > 1000 { + + fmt.Printf("%-15s %-4s %-25s >1000\n", subnet.Subnet, subnet.Vlan, subnet.Name) + } else { + //fmt.Printf("| %-20s | %-20s |\n", "vegetables", "fruits") + fmt.Printf("%-15s %-4s %-25s %v\n", subnet.Subnet, subnet.Vlan, subnet.Name, freeip) + } } else { fmt.Printf("%v:\t%v\t(vl: %v)\n", subnet.Subnet, subnet.Name, subnet.Vlan) + //todo } //} else { // fmt.Printf("%v:\t%v\t(vl: %v)\n", subnet.Subnet, subnet.Name, subnet.Vlan)