Skip to content
Snippets Groups Projects
Commit d196195c authored by Malte Bauch's avatar Malte Bauch
Browse files

WIP

parent 774c7aaa
No related branches found
No related tags found
Loading
Pipeline #99403 failed
......@@ -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
},
}
......
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment