MCPcopy Create free account
hub / github.com/nikivdev/go / normalizeArgs

Function normalizeArgs

cli/spec/main.go:874–898  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

872}
873
874func normalizeArgs(args []string) []string {
875 if len(args) == 0 {
876 return args
877 }
878
879 options := make([]string, 0, len(args))
880 positionals := make([]string, 0, len(args))
881
882 for i := 0; i < len(args); i++ {
883 arg := args[i]
884 if !strings.HasPrefix(arg, "-") || arg == "-" {
885 positionals = append(positionals, arg)
886 continue
887 }
888
889 options = append(options, arg)
890
891 if optionRequiresValue(arg) && i+1 < len(args) {
892 i++
893 options = append(options, args[i])
894 }
895 }
896
897 return append(options, positionals...)
898}
899
900func optionRequiresValue(arg string) bool {
901 if strings.HasPrefix(arg, "-in=") || strings.HasPrefix(arg, "--in=") {

Callers 4

runPromptFunction · 0.85
runExecFunction · 0.85
runReviewFunction · 0.85
runReviewCommentsFunction · 0.85

Calls 1

optionRequiresValueFunction · 0.85

Tested by

no test coverage detected