From d196195c251d470132c0f5f8485765c5e11433d7 Mon Sep 17 00:00:00 2001
From: Malte Bauch <malte.bauch@extern.h-da.de>
Date: Tue, 19 Apr 2022 18:30:37 +0200
Subject: [PATCH] WIP

---
 cli/cmd/pndRemove.go | 14 ++++++++++----
 cli/cmd/prompt.go    |  6 +++++-
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/cli/cmd/pndRemove.go b/cli/cmd/pndRemove.go
index 6ff42079f..0fb318679 100644
--- a/cli/cmd/pndRemove.go
+++ b/cli/cmd/pndRemove.go
@@ -32,7 +32,8 @@ POSSIBILITY OF SUCH DAMAGE.
 package cmd
 
 import (
-	log "github.com/sirupsen/logrus"
+	"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/core"
+	"github.com/pterm/pterm"
 
 	"github.com/google/uuid"
 	"github.com/spf13/cobra"
@@ -42,19 +43,24 @@ import (
 var pndRemoveCmd = &cobra.Command{
 	Use:     "remove",
 	Aliases: []string{"rm"},
-	Short:   "TODO - not yet implemented",
-	Long:    `TODO - not yet implemented`,
+	Short:   "Removes the PND with the provided ID",
+	Long:    "Removes the PND with the provided ID",
 
 	RunE: func(cmd *cobra.Command, args []string) error {
+		spinner, _ := pterm.DefaultSpinner.Start("Fetching changes for type: ", cType.String())
 		pid, err := uuid.Parse(args[0])
 		if err != nil {
+			spinner.Fail(err)
 			return err
 		}
 		resp, err := pndAdapter.RemovePnd(pid)
 		if err != nil {
 			return err
 		}
-		log.Infof("Deletion of PND with ID %v: %s", pid, resp.GetStatus().String())
+		if resp.GetStatus() == core.Status_STATUS_OK {
+			spinner.Success("PND has been deleted, ID: ", pid)
+		}
+		spinner.Fail()
 		return nil
 	},
 }
diff --git a/cli/cmd/prompt.go b/cli/cmd/prompt.go
index 818c32f77..14bec3735 100644
--- a/cli/cmd/prompt.go
+++ b/cli/cmd/prompt.go
@@ -197,7 +197,7 @@ func cobraCommandCompletion(currCmd *cobra.Command, d prompt.Document, inputFlag
 
 func completionBasedOnCmd(c *PromptCompleter, cmd *cobra.Command, inputSplit []string, inputFlags []string, d prompt.Document) []prompt.Suggest {
 	switch cmd {
-	case pndUseCmd, pndGetCmd:
+	case pndUseCmd, pndGetCmd, pndRemoveCmd:
 		if len(inputSplit) < 3 || (len(inputSplit) == 3 && d.GetWordBeforeCursor() != "") {
 			suggestions := c.updateSuggestionsThroughFunc(d, getPnds)
 			return cobraCommandCompletion(cmd, d, inputFlags, suggestions)
@@ -210,6 +210,10 @@ func completionBasedOnCmd(c *PromptCompleter, cmd *cobra.Command, inputSplit []s
 		if len(inputSplit) < 3 || (len(inputSplit) == 3 && d.GetWordBeforeCursor() != "") {
 			return c.updateSuggestionsThroughFunc(d, getConfirmedChanges)
 		}
+	case deviceRemoveCmd:
+		if len(inputSplit) < 3 || (len(inputSplit) == 3 && d.GetWordBeforeCursor() != "") {
+			return c.updateSuggestionsThroughFunc(d, getDevices)
+		}
 	case deviceGetCmd, deviceSetCmd:
 		return deviceGetCompletion(c, d, inputSplit)
 	case deviceShowCmd:
-- 
GitLab