Skip to content

Conversation

@Alstruit
Copy link

@Alstruit Alstruit commented Dec 27, 2024

The original implementation assumed each argument would contain at most one value, which could cause exceptions when attempting to parse multiple values (e.g., -depot "11 12 13") into numeric types.

  • The code also checks if the TypeConverter for the given type T is available and logs a warning if it’s not, preventing potential null-reference issues.

  • It stops parsing values once it encounters a new parameter which is consistent with typical CLI usage patterns.

System.ArgumentException occurs when handling space-separated arguments provided as a single string. GetParameterList<T>() function attempts to parse the string of numbers as a UInt32.
var strParam = args[index];

// Handle the scenario where we have a single space-separated string of values
if (strParam.Contains(" ") && !strParam.StartsWith("-"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If args is already split by space, how would this ever hit?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for in case if the arg is enclosed with quotes. Especially if -dir contains spaces.

@xPaw
Copy link
Member

xPaw commented Dec 29, 2024

To be honest I would prefer #234 rather than trying to hack in support for this in the current system, but System.CommandLine was kind of abandoned...

I've had success using https://github.com/Cysharp/ConsoleAppFramework

@Alstruit
Copy link
Author

Alstruit commented Dec 29, 2024

I agree that this appears to be hacky. To be fair this only happens if one of the arguments is enclosed with quotes.
Im reopening in case if there any interests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants