refactor gpt_params_parse, add validate_params function #74
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The parsing of the parameters is broken.
Basically, parameters were only parsed correctly to arguments if it was the last argument of the command line. For most parameter errors in the middle of the command line, the program terminates without any error message.
A separate validate_params function fixes these problems.
Originally there was the thought to provide the validate function with checks for numeric or string values, but after switching the function to error handling with try/catch it turns out that the
std::stoi
,std::stof
functions then provide these messages for free.Since the help text is very long, it is not very helpful to display the entire help text for each error - on the contrary, this hides the actual error message, because you have to scroll back page by page to be able to read it.
In case of an error, an error message is now displayed that is much more meaningful than before, as well as a reference to the help.