mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-01 15:07:17 +08:00
0620ebe7a4
* commit 'b39963bbfcc47e52eb726b3228ee381710837ddc': climc: add printObjectRecursive() printutils: add PrintJSONObjectRecursive() dep: make dep ensure
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package shell
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"yunion.io/x/jsonutils"
|
|
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
|
"yunion.io/x/onecloud/pkg/util/printutils"
|
|
"yunion.io/x/onecloud/pkg/util/excelutils"
|
|
)
|
|
|
|
func printList(list *modules.ListResult, columns []string) {
|
|
printutils.PrintJSONList(list, columns)
|
|
}
|
|
|
|
func printObject(obj jsonutils.JSONObject) {
|
|
printutils.PrintJSONObject(obj)
|
|
}
|
|
|
|
func printObjectRecursive(obj jsonutils.JSONObject) {
|
|
printutils.PrintJSONObjectRecursive(obj)
|
|
}
|
|
|
|
func printObjectRecursiveEx(obj jsonutils.JSONObject, cb printutils.PrintJSONObjectRecursiveExFunc) {
|
|
printutils.PrintJSONObjectRecursiveEx(obj, cb)
|
|
}
|
|
|
|
func printBatchResults(results []modules.SubmitResult, columns []string) {
|
|
printutils.PrintJSONBatchResults(results, columns)
|
|
}
|
|
|
|
func exportList(list *modules.ListResult, file string, exportKeys string, exportTexts string, columns []string) {
|
|
var keys []string
|
|
var texts []string
|
|
if len(exportKeys) > 0 {
|
|
keys = strings.Split(exportKeys, ",")
|
|
texts = strings.Split(exportTexts, ",")
|
|
}else {
|
|
keys = columns
|
|
texts = columns
|
|
}
|
|
excelutils.ExportFile(list.Data, keys, texts, file)
|
|
}
|