{"record":{"id":"d0fc8d1028ba4a75","repo":"abpframework/abp","slug":"should-specify-an-option-name-after-prefix","errorCode":null,"errorMessage":"Should specify an option name after '--' prefix!","messagePattern":"Should specify an option name after '--' prefix!","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"warning","filePath":"framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineArgumentParser.cs","lineNumber":91,"sourceCode":"    }\n\n    public CommandLineArgs Parse(string lineText)\n    {\n        return Parse(GetArgsArrayFromLine(lineText));\n    }\n\n    private static bool IsOptionName(string argument)\n    {\n        return argument.StartsWith(\"-\") || argument.StartsWith(\"--\");\n    }\n\n    private static string ParseOptionName(string argument)\n    {\n        if (argument.StartsWith(\"--\"))\n        {\n            if (argument.Length <= 2)\n            {\n                throw new ArgumentException(\"Should specify an option name after '--' prefix!\");\n            }\n\n            return argument.RemovePreFix(\"--\");\n        }\n\n        if (argument.StartsWith(\"-\"))\n        {\n            if (argument.Length <= 1)\n            {\n                throw new ArgumentException(\"Should specify an option name after '-' prefix!\");\n            }\n\n            return argument.RemovePreFix(\"-\");\n        }\n\n        throw new ArgumentException(\"Option names should start with '-' or '--'.\");\n    }\n","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/abpframework/abp/blob/7ed43b1931b9df46a50c0c59148a18645641d0df/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineArgumentParser.cs#L73-L109","documentation":"Thrown by CommandLineArgumentParser.ParseOptionName when an argument equals exactly '--' (length <= 2 after the prefix check). The parser expects a name token immediately after the '--' prefix; a bare '--' with no following characters is not a valid option name. This is part of the ABP CLI's internal argument tokenizer.","triggerScenarios":"The CLI is invoked with a standalone '--' token, e.g., 'abp new MyProj --' or a script passes an empty '--'. GetArgsArrayFromLine yields '--' as a token and the options loop feeds it to ParseOptionName.","commonSituations":"User typo at the terminal; a wrapper script or CI step that concatenates flags and emits an empty '--'; copy-pasting a command where a flag value was deleted but the '--' left behind; shell glob/quoting producing an empty double-dash token.","solutions":["Remove the bare '--' from the command line; every option must have a name after the prefix.","Inspect the exact arguments passed (print argv) to find which token is the empty '--'.","If generating commands programmatically, filter out tokens that are exactly '--' or '-' before invoking the parser.","Use a single '-' prefix or fully named options ('--version') and ensure no token is left truncated."],"exampleFix":"# before\nabp new MyProject --\n# after (remove the bare double-dash)\nabp new MyProject --version","handlingStrategy":"validation","validationCode":"// Sanitize argument tokens before invoking the CLI parser.\nvar sanitized = args.Where(a => a != \"--\").ToArray();\nif (sanitized.Length != args.Length)\n{\n    Console.Error.WriteLine(\"Removed empty '--' token from arguments.\");\n}\nvar parsed = parser.Parse(sanitized);","typeGuard":"public static bool IsValidOptionToken(string arg) =>\n    !arg.StartsWith(\"--\") || arg.Length > 2;","tryCatchPattern":"try\n{\n    var cmd = parser.Parse(args);\n}\ncatch (ArgumentException ex) when (ex.Message.Contains(\"'--' prefix\", StringComparison.Ordinal))\n{\n    Console.Error.WriteLine($\"Invalid CLI input: a bare '--' is not allowed. Args: {string.Join(' ', args)}\");\n    return ExitCodes.InvalidArguments;\n}","preventionTips":["Avoid passing bare '--' tokens; always follow the prefix with an option name.","When building commands programmatically, filter out empty or prefix-only tokens.","Validate generated command strings before shelling out.","Quote values to prevent the tokenizer from emitting stray tokens."],"tags":["cli","args","parsing","user-input"],"backgroundTag":null,"analyzedSha":"7ed43b1931b9df46a50c0c59148a18645641d0df","analyzedAt":"2026-08-13T16:26:11.351Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}