mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-21 07:08:45 +05:00
simpler console command interface
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package engine
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
@@ -318,3 +319,27 @@ func (ps *ProxyUserService) AddIndex(indexes []string, reply *string) error {
|
||||
func (ps *ProxyUserService) GetIndexes(in string, reply *map[string][]string) error {
|
||||
return ps.Client.Call("UsersV1.AddIndex", in, reply)
|
||||
}
|
||||
|
||||
func ToMapStringString(in interface{}) (map[string]string, error) {
|
||||
out := make(map[string]string)
|
||||
|
||||
v := reflect.ValueOf(in)
|
||||
if v.Kind() == reflect.Ptr {
|
||||
v = v.Elem()
|
||||
in = v.Interface()
|
||||
}
|
||||
typ := reflect.TypeOf(in)
|
||||
for i := 0; i < v.NumField(); i++ {
|
||||
// gets us a StructField
|
||||
field := typ.Field(i)
|
||||
typField := v.Field(i)
|
||||
switch typField.Kind() {
|
||||
case reflect.String:
|
||||
val := v.Field(i).String()
|
||||
if val != "" {
|
||||
out[field.Name] = val
|
||||
}
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user