(schema map[string]any)
| 735 | } |
| 736 | |
| 737 | func buildArguments(schema map[string]any) map[string]any { |
| 738 | args := make(map[string]any) |
| 739 | if schema == nil { |
| 740 | argsStr := interactiveReadLineDefault(" Arguments (JSON)", "{}") |
| 741 | _ = json.Unmarshal([]byte(argsStr), &args) |
| 742 | return args |
| 743 | } |
| 744 | |
| 745 | props, ok := schema["properties"].(map[string]any) |
| 746 | if !ok || len(props) == 0 { |
| 747 | argsStr := interactiveReadLineDefault(" Arguments (JSON)", "{}") |
| 748 | _ = json.Unmarshal([]byte(argsStr), &args) |
| 749 | return args |
| 750 | } |
| 751 | |
| 752 | fmt.Println(" Fill in parameters from schema (enter to skip):") |
| 753 | required := getRequired(schema) |
| 754 | |
| 755 | for name, propRaw := range props { |
| 756 | prop, ok := propRaw.(map[string]any) |
| 757 | if !ok { |
| 758 | continue |
| 759 | } |
| 760 | propType, _ := prop["type"].(string) |
| 761 | desc, _ := prop["description"].(string) |
| 762 | |
| 763 | reqMarker := "" |
| 764 | if required[name] { |
| 765 | reqMarker = " *required" |
| 766 | } |
| 767 | |
| 768 | hint := fmt.Sprintf(" | %s (%s%s)", name, propType, reqMarker) |
| 769 | if desc != "" { |
| 770 | if len(desc) > 50 { |
| 771 | desc = desc[:50] + "..." |
| 772 | } |
| 773 | hint += " - " + desc |
| 774 | } |
| 775 | fmt.Println(hint) |
| 776 | |
| 777 | val := interactiveReadLine(" | value: ") |
| 778 | if val == "" { |
| 779 | continue |
| 780 | } |
| 781 | |
| 782 | switch propType { |
| 783 | case "integer": |
| 784 | if n, err := strconv.Atoi(val); err == nil { |
| 785 | args[name] = n |
| 786 | continue |
| 787 | } |
| 788 | case "boolean": |
| 789 | if val == "true" { |
| 790 | args[name] = true |
| 791 | continue |
| 792 | } else if val == "false" { |
| 793 | args[name] = false |
| 794 | continue |
no test coverage detected