Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixing issues with arguments with optional values lonely in a command. #10

Merged
merged 1 commit into from

2 participants

@igorsantos07

This closes #9.

I've added what @dlussky suggested and extended the fix to takeOptionValue as well. Lastly, be default the option with no value would get a "null" as value, what makes it behave as if it wasn't set. Thus, I'm setting it to "true" if it's there but there's no value. Does that make sense? Is there another place where this change should be replicated?

@c9s c9s merged commit c235453 into from
@igorsantos07

Thanks @c9s! Would you mind releasing a new tag so we can update accordingly?

@c9s
Owner
c9s commented

Sure!

@c9s
Owner
c9s commented

1.2.5 just got released!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/GetOptionKit/OptionParser.php
View
7 src/GetOptionKit/OptionParser.php
@@ -72,9 +72,12 @@ function takeOptionValue($spec,$arg,$next)
if( $arg->containsOptionValue() ) {
$spec->setValue( $arg->getOptionValue() );
}
- elseif( ! $next->isOption() ) {
+ elseif( $next && ! $next->isOption() ) {
$spec->setValue( $next->arg );
}
+ else {
+ $spec->setValue(true);
+ }
}
/*
@@ -94,7 +97,7 @@ function foundRequireValue($spec,$arg,$next)
if( $arg->containsOptionValue() )
return true;
- if( ! $arg->containsOptionValue() && ! $next->isEmpty() && ! $next->isOption() )
+ if( ! $arg->containsOptionValue() && $next && ! $next->isEmpty() && ! $next->isOption() )
return true;
return false;
Something went wrong with that request. Please try again.