-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autoparsing on get option causes later option rules not to trip #85
Comments
@nategood I'll take this and PR it to you if you'll accept the spec. |
All of the options would be parsed again every time an option operator was called. The current library architecture does not allow for this without performance impact, I believe. You can manually call Commando's parse function at any time to execute options that were added after the initial parse. When accessing the command as an array the parse is executed, and a flag is set to keep the execution from happening again. |
Ok, that's fair. It seems like it would be easy enough to unset the public function __call($name, $arguments)
{
// ...
$option = call_user_func_array(array($this, "_$name"), $arguments);
$this->parsed = false;
return $this;
} That way we can avoid incurring the parse penalty on every change, but we can make sure that new changes trigger future parsing in the same way that initial changes do. |
The only problem with this idea, is that it will make validation and other rules like |
It would be up to the user to manage error handling, at that point. Are you talking about only on new options, or when modifying an existing option? I rather like the idea of the user controlling when parsing occurs better. There is already confusion with the behavior around parsing, and I think this will add to that, personally. |
Yes, maybe that's the way to go: remove auto-parsing entirely and state clearly in the documentation that you must call |
Right. I would want some input from @nategood on the subject. Either there needs to be a sane way to invalidate the currently parsed options and re-parse (automatically) or parsing should just be a manual step that is called explicitly as needed by the user. I personally think the manual option is the best way to go. Automatic parsing in the current state of the library can cause a lot of headaches around rules/needs/must etc...in all but the most basic commands. For instance I like to parse before setting a |
Given this script:
Expected Behavior
required
called on option 'e'.must
called on option 'e'.Actual Behavior
Does not show any errors at all, and outputs any value given for option 'e'.
The text was updated successfully, but these errors were encountered: