Add autocomplete for UNI command in BBSimctl

Change-Id: Ic3f36d5932200e22df057fe36ad892edd39636bf
diff --git a/internal/bbsimctl/commands/uni.go b/internal/bbsimctl/commands/uni.go
index ba1c795..81f7c96 100644
--- a/internal/bbsimctl/commands/uni.go
+++ b/internal/bbsimctl/commands/uni.go
@@ -20,6 +20,8 @@
 import (
 	"context"
 	"os"
+	"strconv"
+	"strings"
 
 	"github.com/jessevdk/go-flags"
 	pb "github.com/opencord/bbsim/api/bbsim"
@@ -139,3 +141,32 @@
 
 	return nil
 }
+
+func (uniId *UniIdInt) Complete(match string) []flags.Completion {
+	client, conn := connect()
+	defer conn.Close()
+
+	ctx, cancel := context.WithTimeout(context.Background(), config.GlobalConfig.Grpc.Timeout)
+	defer cancel()
+
+	onus, err := client.GetONUs(ctx, &pb.Empty{})
+	if err != nil {
+		log.Fatalf("could not get ONUs: %v", err)
+		return nil
+	}
+
+	// go-flag doesn't allow us to read the previous parameters to the command so we can't get the ONU Serial Number,
+	// but since all the ONUs have the same number of UNIs thus we can re-use the UNIs belonging to the first ONU in the list
+	// pending issue here https://github.com/jessevdk/go-flags/issues/305
+	unis := onus.Items[0].Unis
+
+	list := make([]flags.Completion, 0)
+	for _, uni := range unis {
+		strID := strconv.Itoa(int(uni.ID))
+		if strings.HasPrefix(strID, match) {
+			list = append(list, flags.Completion{Item: strID})
+		}
+	}
+
+	return list
+}