MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / buildArguments

Function buildArguments

cmd/inject-cli/main.go:737–805  ·  view source on GitHub ↗
(schema map[string]any)

Source from the content-addressed store, hash-verified

735}
736
737func 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

Callers 1

cmdRulesAddFunction · 0.85

Calls 3

getRequiredFunction · 0.85
interactiveReadLineFunction · 0.85

Tested by

no test coverage detected