Skip to content
Snippets Groups Projects

Improve usability and better output formatting for gosndc

Merged Malte Bauch requested to merge cli-refactoring-pterm into develop
2 files
+ 15
5
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 10
4
@@ -32,7 +32,8 @@ POSSIBILITY OF SUCH DAMAGE.
@@ -32,7 +32,8 @@ POSSIBILITY OF SUCH DAMAGE.
package cmd
package cmd
import (
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/google/uuid"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
@@ -42,19 +43,24 @@ import (
@@ -42,19 +43,24 @@ import (
var pndRemoveCmd = &cobra.Command{
var pndRemoveCmd = &cobra.Command{
Use: "remove",
Use: "remove",
Aliases: []string{"rm"},
Aliases: []string{"rm"},
Short: "TODO - not yet implemented",
Short: "Removes the PND with the provided ID",
Long: `TODO - not yet implemented`,
Long: "Removes the PND with the provided ID",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
 
spinner, _ := pterm.DefaultSpinner.Start("Fetching changes for type: ", cType.String())
pid, err := uuid.Parse(args[0])
pid, err := uuid.Parse(args[0])
if err != nil {
if err != nil {
 
spinner.Fail(err)
return err
return err
}
}
resp, err := pndAdapter.RemovePnd(pid)
resp, err := pndAdapter.RemovePnd(pid)
if err != nil {
if err != nil {
return err
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
return nil
},
},
}
}
Loading