Fix NoValue field, Fix MaxLen when header name is > value
This commit is contained in:
parent
26166489fd
commit
3fdca54cc4
28
cmd/list.go
28
cmd/list.go
@ -47,13 +47,13 @@ func displayStructFields(jails []Jail, valsToDisplay []string) {
|
||||
line := make([]Field, len(valsToDisplay))
|
||||
for i, f := range valsToDisplay {
|
||||
a := reflect.ValueOf(&tj).Elem()
|
||||
//fmt.Printf("Struct : %s, Champ : %s\n", a.String(), f)
|
||||
//fmt.Printf("%v", a.Elem().FieldByName(f).Interface())
|
||||
field := Field {
|
||||
Name: f,
|
||||
}
|
||||
if a.Elem().FieldByName(f).IsValid() {
|
||||
// For now this just contains this item length, will adjust later
|
||||
MaxLen: len(fmt.Sprintf("%v", a.Elem().FieldByName(f).Interface())),
|
||||
Value: fmt.Sprintf("%v", a.Elem().FieldByName(f).Interface()),
|
||||
field.MaxLen = len(fmt.Sprintf("%v", a.Elem().FieldByName(f).Interface()))
|
||||
field.Value = fmt.Sprintf("%v", a.Elem().FieldByName(f).Interface())
|
||||
}
|
||||
line[i] = field
|
||||
|
||||
@ -64,7 +64,7 @@ func displayStructFields(jails []Jail, valsToDisplay []string) {
|
||||
// Get real maximum length
|
||||
maxlen := make([]int, len(valsToDisplay))
|
||||
for i := 0; i< len(valsToDisplay); i++ {
|
||||
maxlen[i] = 0
|
||||
maxlen[i] = len(valsToDisplay[i])
|
||||
}
|
||||
for _, l := range out {
|
||||
for i, f := range l {
|
||||
@ -83,7 +83,7 @@ func displayStructFields(jails []Jail, valsToDisplay []string) {
|
||||
}
|
||||
|
||||
totalLen := 0
|
||||
// Add separator and 2 blank spaces
|
||||
// For each field, add separator and 2 blank spaces
|
||||
for _, f := range out[0] {
|
||||
totalLen += f.MaxLen + 3
|
||||
}
|
||||
@ -145,16 +145,7 @@ func listJails(args []string) {
|
||||
listJailsFromDatastore(d)
|
||||
}
|
||||
|
||||
displayStructFields(gJails, []string{"JID", "Name", "RootPath"})
|
||||
|
||||
/* for _, j := range (gJails) {
|
||||
if j.Running {
|
||||
fmt.Printf("%d ; %s ; %s ; %s\n", j.JID, j.Name, j.Config.Ip4_addr, j.Config.Release)
|
||||
} else {
|
||||
fmt.Printf(" ; %s ; %s ; %s\n", j.Name, j.Config.Ip4_addr, j.Config.Release)
|
||||
}
|
||||
}
|
||||
*/
|
||||
displayStructFields(gJails, []string{"JID", "Name", "Release", "RootPath"})
|
||||
}
|
||||
|
||||
|
||||
@ -196,9 +187,6 @@ func listJailsFromDirectory(dir string) ([]Jail) {
|
||||
}
|
||||
|
||||
// 3. Add current running informations
|
||||
// FIXME : use rj.host.hostname
|
||||
//j.Internal_name = fmt.Sprintf("ioc-%s", j.Name)
|
||||
|
||||
rjails, err := jail.GetJails()
|
||||
if err != nil { log.Fatalln("Unable to list running jails") }
|
||||
for _, rj := range rjails {
|
||||
@ -225,7 +213,5 @@ func getJailConfig(jailConfigPath string) (JailConfig, error) {
|
||||
err = json.Unmarshal([]byte(content), &jc)
|
||||
if err != nil { log.Fatalln(fmt.Sprintf("Error occured during unmarshaling %s: %s", jailConfigPath, err.Error())) }
|
||||
|
||||
//fmt.Printf("Jail Config: %#v\n", jc)
|
||||
|
||||
return jc, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user