ListJailsProps() : Replace unused args with format
This commit is contained in:
parent
4cc1c476aa
commit
9d7db268cc
26
cmd/list.go
26
cmd/list.go
@ -15,23 +15,37 @@ import (
|
||||
* List all properties a jail have, with their internal name
|
||||
* Only print properties name. To get name & values, use GetJailProperties()
|
||||
*******************************************************************************/
|
||||
func ListJailsProps(args []string) {
|
||||
func ListJailsProps(format string) (string, error) {
|
||||
var conf Jail
|
||||
var result []string
|
||||
var props []string
|
||||
var out string
|
||||
// Mandatory constructor to init default values
|
||||
jailconf, err := NewJailConfig()
|
||||
if err != nil {
|
||||
fmt.Printf("Error allocating JailConfig: %s\n", err.Error())
|
||||
return
|
||||
return out, err
|
||||
}
|
||||
|
||||
conf.Config = jailconf
|
||||
|
||||
result = getStructFieldNames(conf, result, "")
|
||||
props = getStructFieldNames(conf, props, "")
|
||||
|
||||
for _, f := range result {
|
||||
fmt.Printf("%s\n", f)
|
||||
if format == "json" {
|
||||
out = "{\"properties\":["
|
||||
for i, p := range props {
|
||||
out += fmt.Sprintf("\"%s\"", p)
|
||||
if i < len(props) - 1 {
|
||||
out += ","
|
||||
}
|
||||
}
|
||||
out += "]}"
|
||||
} else {
|
||||
for _, p := range props {
|
||||
out += fmt.Sprintf("%s\n", p)
|
||||
}
|
||||
}
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user