diff --git a/cli/cmd/pndRemove.go b/cli/cmd/pndRemove.go index 6ff42079f7f3c69b273a1ee7461ea4e5041188b2..0fb318679c754cf36fa797f276401cb1a4acdde2 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 818c32f77ff4863bb01b7372083a76981443d7ef..14bec3735253366acae8b56529ba2147e1a8959d 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: