Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Jul 18, 2022
1 parent a305e13 commit a854abd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func ActionConfigs() Action {
if err != nil {
return ActionMessage(err.Error())
}
return ActionValuesDescribed(fields...).Invoke(c).Suffix("=").ToA()
return ActionStyledValuesDescribed(fields...).Invoke(c).Suffix("=").ToA()
default:
return ActionValues()
}
Expand Down
17 changes: 10 additions & 7 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ func (c configMap) Fields(name string) ([]string, error) {
if i, ok := c[name]; ok {
fields := make([]string, 0)
t := reflect.TypeOf(i).Elem()
v := reflect.ValueOf(i).Elem()
//v := reflect.ValueOf(i).Elem()
for index := 0; index < t.NumField(); index++ {
field := t.Field(index)
if field.Type.Name() != "string" {
return nil, fmt.Errorf("invalid field type [name: '%v', type: '%v']", field.Name, field.Type.Name())
}
fields = append(fields, field.Name, field.Tag.Get("desc"), v.FieldByName(field.Name).String())
// if field.Type.Name() != "string" {
// return nil, fmt.Errorf("invalid field type [name: '%v', type: '%v']", field.Name, field.Type.Name())
// }
//fields = append(fields, field.Name, field.Tag.Get("desc"), v.FieldByName(field.Name).String())
fields = append(fields, field.Name, field.Tag.Get("desc"), "")
}
return fields, nil
}
Expand Down Expand Up @@ -93,8 +94,10 @@ func SetConfig(key, value string) error {
return set("configs", key, strings.Replace(value, ",", " ", -1))
}

func GetStyleConfigs() []string { return config.Styles.Keys() }
func GetStyleFields(name string) ([]string, error) { return config.Styles.Fields(name) }
func GetConfigs() []string { return config.Configs.Keys() }
func GetConfigFields(name string) ([]string, error) { return config.Configs.Fields(name) }
func GetStyleConfigs() []string { return config.Styles.Keys() }
func GetStyleFields(name string) ([]string, error) { return config.Styles.Fields(name) }
func SetStyle(key, value string) error {
return set("styles", key, strings.Replace(value, ",", " ", -1))
}
Expand Down

0 comments on commit a854abd

Please sign in to comment.