{"record":{"id":"5fb0198b015923d2","repo":"Jguer/yay","slug":"only-one-operation-may-be-used-at-a-time","errorCode":null,"errorMessage":"only one operation may be used at a time","messagePattern":"only one operation may be used at a time","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/settings/parser/parser.go","lineNumber":163,"sourceCode":"\t\tcase a.ExistsArg(\"g\", \"groups\"):\n\t\t\treturn false\n\t\tcase a.ExistsArg(\"i\", \"info\"):\n\t\t\treturn false\n\t\tcase a.ExistsArg(\"c\", \"clean\") && mode == ModeAUR:\n\t\t\treturn false\n\t\t}\n\n\t\treturn true\n\tcase \"U\", \"upgrade\":\n\t\treturn true\n\tdefault:\n\t\treturn false\n\t}\n}\n\nfunc (a *Arguments) addOP(op string) error {\n\tif a.Op != \"\" {\n\t\treturn errors.New(gotext.Get(\"only one operation may be used at a time\"))\n\t}\n\n\ta.Op = op\n\n\treturn nil\n}\n\nfunc (a *Arguments) addParam(option, arg string) error {\n\tif !isArg(option) {\n\t\treturn errors.New(gotext.Get(\"invalid option '%s'\", option))\n\t}\n\n\tif isOp(option) {\n\t\treturn a.addOP(option)\n\t}\n\n\ta.CreateOrAppendOption(option, strings.Split(arg, \",\")...)\n","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/Jguer/yay/blob/328f4b4939fb35f38c2f7c7ce3b8638a839bafa5/pkg/settings/parser/parser.go#L145-L181","documentation":"addOP in pkg/settings/parser/parser.go enforces that an Arguments struct holds exactly one pacman-style operation (e.g. -S, -Q, -R). If a.Op is already set and another operation is passed, it rejects the parse with 'only one operation may be used at a time'. This mirrors pacman's CLI contract where operations are mutually exclusive.","triggerScenarios":"Calling AddArg/parseShortOption/parseLongOption with a second operation flag while one is already recorded, e.g. adding both 'S' and 'Q' (via addParam -> isOp -> addOP).","commonSituations":"Command lines like 'yay -Sy -Qi pkg' or programmatically appending a second op to an Arguments struct; shell scripts concatenating pacman flags from different commands; typos turning an option into an operation.","solutions":["Remove all but one operation flag from the command line (keep -S OR -Q, not both).","Split into separate invocations, e.g. run 'yay -Sy' then 'yay -Qi pkg'.","Check shell variables/aliases that prepend extra operation flags before constructing the Arguments.","Fix programmatic callers to check a.Op != \"\" before calling AddArg with another operation."],"exampleFix":"// before\nargs.Parse() with: yay -Sy -Qi linux\n// after\nyay -Sy && yay -Qi linux","handlingStrategy":"validation","validationCode":"ops := []string{\"S\", \"Q\", \"R\", \"U\", \"F\", \"T\"}\ncount := 0\nfor _, a := range argv {\n    if slices.Contains(ops, strings.TrimLeft(a, \"-\")) {\n        count++\n    }\n}\nif count > 1 {\n    return errors.New(\"pass only one pacman operation per invocation\")\n}","typeGuard":null,"tryCatchPattern":"err := args.Parse() // or AddArg(op)\nif err != nil {\n    if strings.Contains(err.Error(), \"only one operation may be used\") {\n        return usageError(\"combine incompatible operations; split into separate commands\")\n    }\n    return err\n}","preventionTips":["Never combine pacman-style operation flags (-S with -Q, etc.) in one invocation","Audit shell scripts/aliases that prepend operation flags","Programmatically, check Arguments.Op == \"\" before adding another operation","Split multi-operation work into sequential command runs"],"tags":["cli","arguments","parser","pacman"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"328f4b4939fb35f38c2f7c7ce3b8638a839bafa5","analyzedAt":"2026-09-07T16:45:12.608Z","contentChangedAt":"2026-09-07T16:45:12.608Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}