{"record":{"id":"cc87ec8eee5caa73","repo":"BCUninstaller/Bulk-Crap-Uninstaller","slug":"argument-has-been-specified-more-than-once-expe","errorCode":null,"errorMessage":"{argument} has been specified more than once, expecting single value","messagePattern":"(.+?) has been specified more than once, expecting single value","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"source/KlocTools/IO/Arguments.cs","lineNumber":192,"sourceCode":"        /// Determines whether the specified argument is true.\n        /// </summary>\n        /// <param name=\"argument\">The argument.</param>\n        /// <returns>\n        ///     <c>true</c> if the specified argument is true; otherwise, <c>false</c>.\n        /// </returns>\n        public bool IsTrue(string argument)\n        {\n            AssertSingle(argument);\n\n            var arg = this[argument];\n\n            return arg != null && arg[0].Equals(\"true\", StringComparison.OrdinalIgnoreCase);\n        }\n\n        private void AssertSingle(string argument)\n        {\n            if (this[argument] != null && this[argument].Count > 1)\n                throw new ArgumentException($\"{argument} has been specified more than once, expecting single value\");\n        }\n\n        public string Single(string argument)\n        {\n            AssertSingle(argument);\n\n            //only return value if its NOT true, there is only a single item for that argument\n            //and the argument is defined\n            if (this[argument] != null && !IsTrue(argument))\n                return this[argument][0];\n\n            return null;\n        }\n\n        public bool Exists(string argument)\n        {\n            return (this[argument] != null && this[argument].Count > 0);\n        }","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/BCUninstaller/Bulk-Crap-Uninstaller/blob/608321de98e92297377b1eb69029af55c25504a1/source/KlocTools/IO/Arguments.cs#L174-L210","documentation":"AssertSingle is called by IsTrue() and Single() to guard against ambiguous reads. If an argument was added more than once (via Add()), reading it as a single value throws ArgumentException because the intended value is ambiguous. The message names the offending argument.","triggerScenarios":"Input with repeated flags that is then read via Single() or IsTrue(); switch flags accidentally duplicated by quoting in a script.","commonSituations":"A script passing /flag twice; argument sources merged without dedup; a toggle flag repeated.","solutions":["Remove duplicates before reading the value.","Use the multi-value indexer (this[argument]) instead of Single() when duplicates are expected.","Validate per-argument counts during parsing and reject/normalize early."],"exampleFix":"// before\nstring v = args.Single(\"file\"); // throws if --file given twice\n// after\nvar list = args[\"file\"];\nstring v = list != null ? list[0] : null;","handlingStrategy":"validation","validationCode":"var list = args[argument];\nif (list != null && list.Count > 1)\n    /* pick a value or reject rather than calling Single/IsTrue */","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Deduplicate flag input before reading.","Use the multi-value indexer when duplicates are legitimate."],"tags":["cli","arguments","validation"],"backgroundTag":null,"analyzedSha":"608321de98e92297377b1eb69029af55c25504a1","analyzedAt":"2026-08-13T12:17:35.389Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}