abpframework/abp · warning · ArgumentException
Should specify an option name after '--' prefix!
Error message
Should specify an option name after '--' prefix!
What it means
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.
Source
Thrown at framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineArgumentParser.cs:91
}
public CommandLineArgs Parse(string lineText)
{
return Parse(GetArgsArrayFromLine(lineText));
}
private static bool IsOptionName(string argument)
{
return argument.StartsWith("-") || argument.StartsWith("--");
}
private static string ParseOptionName(string argument)
{
if (argument.StartsWith("--"))
{
if (argument.Length <= 2)
{
throw new ArgumentException("Should specify an option name after '--' prefix!");
}
return argument.RemovePreFix("--");
}
if (argument.StartsWith("-"))
{
if (argument.Length <= 1)
{
throw new ArgumentException("Should specify an option name after '-' prefix!");
}
return argument.RemovePreFix("-");
}
throw new ArgumentException("Option names should start with '-' or '--'.");
}
View on GitHub (pinned to 7ed43b1931)
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.
Example fix
# before abp new MyProject -- # after (remove the bare double-dash) abp new MyProject --version
Defensive patterns
Strategy: validation
Validate before calling
// Sanitize argument tokens before invoking the CLI parser.
var sanitized = args.Where(a => a != "--").ToArray();
if (sanitized.Length != args.Length)
{
Console.Error.WriteLine("Removed empty '--' token from arguments.");
}
var parsed = parser.Parse(sanitized); Type guard
public static bool IsValidOptionToken(string arg) =>
!arg.StartsWith("--") || arg.Length > 2; Try / catch
try
{
var cmd = parser.Parse(args);
}
catch (ArgumentException ex) when (ex.Message.Contains("'--' prefix", StringComparison.Ordinal))
{
Console.Error.WriteLine($"Invalid CLI input: a bare '--' is not allowed. Args: {string.Join(' ', args)}");
return ExitCodes.InvalidArguments;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Should specify an option name after '-' prefix!
- Option names should start with '-' or '--'.
- There is no template found with given name: {name}
- "public class" declaration not found!
- ERROR: Remote server returns '{response.StatusCode}'
AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13).
Data as JSON: /api/errors/d0fc8d1028ba4a75.
Report an issue: GitHub.