VOL-2168 - add the ability to specify default formats and ordering

Change-Id: Ie867bbd8d055e34f26eb43466a92f1d1954e35d4
diff --git a/internal/pkg/commands/devicegroups.go b/internal/pkg/commands/devicegroups.go
index 7314b0a..4d206c7 100644
--- a/internal/pkg/commands/devicegroups.go
+++ b/internal/pkg/commands/devicegroups.go
@@ -22,7 +22,6 @@
 	"github.com/jhump/protoreflect/dynamic"
 	"github.com/opencord/voltctl/pkg/format"
 	"github.com/opencord/voltctl/pkg/model"
-	"log"
 )
 
 const (
@@ -42,7 +41,7 @@
 func RegisterDeviceGroupCommands(parser *flags.Parser) {
 	if _, err := parser.AddCommand("devicegroup", "device group commands", "Commands to query and manipulate VOLTHA device groups",
 		&deviceGroupOpts); err != nil {
-		log.Fatalf("Unexpected error while attempting to register device group commands : %s", err)
+		Error.Fatalf("Unexpected error while attempting to register device group commands : %s", err)
 	}
 }
 
@@ -54,7 +53,7 @@
 	}
 	defer conn.Close()
 
-	descriptor, method, err := GetMethod("devicegroup-list")
+	descriptor, method, err := GetMethod("device-group-list")
 	if err != nil {
 		return err
 	}
@@ -84,11 +83,15 @@
 
 	outputFormat := CharReplacer.Replace(options.Format)
 	if outputFormat == "" {
-		outputFormat = DEFAULT_DEVICE_GROUP_FORMAT
+		outputFormat = GetCommandOptionWithDefault("device-group-list", "format", DEFAULT_DEVICE_GROUP_FORMAT)
 	}
 	if options.Quiet {
 		outputFormat = "{{.Id}}"
 	}
+	orderBy := options.OrderBy
+	if orderBy == "" {
+		orderBy = GetCommandOptionWithDefault("device-group-list", "order", "")
+	}
 
 	data := make([]model.DeviceGroup, len(items.([]interface{})))
 	for i, item := range items.([]interface{}) {
@@ -99,7 +102,7 @@
 	result := CommandResult{
 		Format:    format.Format(outputFormat),
 		Filter:    options.Filter,
-		OrderBy:   options.OrderBy,
+		OrderBy:   orderBy,
 		OutputAs:  toOutputType(options.OutputAs),
 		NameLimit: options.NameLimit,
 		Data:      data,