VOL-2168 - add the ability to specify default formats and ordering
Change-Id: Ie867bbd8d055e34f26eb43466a92f1d1954e35d4
diff --git a/internal/pkg/commands/adapter.go b/internal/pkg/commands/adapter.go
index 067b64c..b777889 100644
--- a/internal/pkg/commands/adapter.go
+++ b/internal/pkg/commands/adapter.go
@@ -22,7 +22,6 @@
"github.com/jhump/protoreflect/dynamic"
"github.com/opencord/voltctl/pkg/format"
"github.com/opencord/voltctl/pkg/model"
- "log"
)
const (
@@ -41,7 +40,7 @@
func RegisterAdapterCommands(parent *flags.Parser) {
if _, err := parent.AddCommand("adapter", "adapter commands", "Commands to query and manipulate VOLTHA adapters", &adapterOpts); err != nil {
- log.Fatalf("Unexpected error while attempting to register adapter commands : %s", err)
+ Error.Fatalf("Unexpected error while attempting to register adapter commands : %s", err)
}
}
@@ -81,12 +80,15 @@
outputFormat := CharReplacer.Replace(options.Format)
if outputFormat == "" {
- outputFormat = DEFAULT_OUTPUT_FORMAT
+ outputFormat = GetCommandOptionWithDefault("adapter-list", "format", DEFAULT_OUTPUT_FORMAT)
}
-
if options.Quiet {
outputFormat = "{{.Id}}"
}
+ orderBy := options.OrderBy
+ if orderBy == "" {
+ orderBy = GetCommandOptionWithDefault("adapter-list", "order", "")
+ }
data := make([]model.Adapter, len(items.([]interface{})))
for i, item := range items.([]interface{}) {
@@ -96,7 +98,7 @@
result := CommandResult{
Format: format.Format(outputFormat),
Filter: options.Filter,
- OrderBy: options.OrderBy,
+ OrderBy: orderBy,
OutputAs: toOutputType(options.OutputAs),
NameLimit: options.NameLimit,
Data: data,