* @param $force boolean Whether to force the help to show, default false
*/
protected function maybeHelp( $force = false ) {
+ if( !$force && !$this->hasOption( 'help' ) ) {
+ return;
+ }
+
$screenWidth = 80; // TODO: Caculate this!
$tab = " ";
$descWidth = $screenWidth - ( 2 * strlen( $tab ) );
ksort( $this->mParams );
- if ( $this->hasOption( 'help' ) || $force ) {
- $this->mQuiet = false;
+ $this->mQuiet = false;
- if ( $this->mDescription ) {
- $this->output( "\n" . $this->mDescription . "\n" );
- }
- $output = "\nUsage: php " . basename( $this->mSelf );
- if ( $this->mParams ) {
- $output .= " [--" . implode( array_keys( $this->mParams ), "|--" ) . "]";
- }
- if ( $this->mArgList ) {
- $output .= " <";
- foreach ( $this->mArgList as $k => $arg ) {
- $output .= $arg['name'] . ">";
- if ( $k < count( $this->mArgList ) - 1 )
- $output .= " <";
- }
- }
- $this->output( "$output\n" );
- foreach ( $this->mParams as $par => $info ) {
- $this->output(
- wordwrap( "$tab$par : " . $info['desc'], $descWidth,
- "\n$tab$tab" ) . "\n"
- );
- }
- foreach ( $this->mArgList as $info ) {
- $this->output(
- wordwrap( "$tab<" . $info['name'] . "> : " .
- $info['desc'], $descWidth, "\n$tab$tab" ) . "\n"
- );
+ // Description ...
+ if ( $this->mDescription ) {
+ $this->output( "\n" . $this->mDescription . "\n" );
+ }
+ $output = "\nUsage: php " . basename( $this->mSelf );
+
+ // ... append parameters ...
+ if ( $this->mParams ) {
+ $output .= " [--" . implode( array_keys( $this->mParams ), "|--" ) . "]";
+ }
+
+ // ... and append arguments.
+ if ( $this->mArgList ) {
+ $output .= " <";
+ foreach ( $this->mArgList as $k => $arg ) {
+ $output .= $arg['name'] . ">";
+ if ( $k < count( $this->mArgList ) - 1 )
+ $output .= " <";
}
- die( 1 );
}
+ $this->output( "$output\n\n" );
+
+ // Parameters description
+ foreach ( $this->mParams as $par => $info ) {
+ $this->output(
+ wordwrap( "$tab--$par: " . $info['desc'], $descWidth,
+ "\n$tab$tab" ) . "\n"
+ );
+ }
+
+ // Arguments description
+ foreach ( $this->mArgList as $info ) {
+ $this->output(
+ wordwrap( "$tab<" . $info['name'] . ">: " .
+ $info['desc'], $descWidth, "\n$tab$tab" ) . "\n"
+ );
+ }
+
+ die( 1 );
}
/**
$this->assertNet( '10.128.0.0' , '10.135.0.0/9' );
$this->assertNet( '134.0.0.0' , '134.0.5.1/8' );
}
+
+ function testIPv6SpecialRanges() {
+ $this->assertTrue( IPv6::isULA( 'fdc1:9d57:401e::' ) );
+ $this->assertTrue( IPv6::isULA( 'FDC1:9D57:401E::' ) );
+ $this->assertTrue( IPv6::isULA( 'fc::' ) );
+ $this->assertTrue( IPv6::isULA( 'fdff:ffff:ffff::' ) );
+
+ $this->assertFalse( IPv6::isULA( '2001:0DB8::A:1::' ) );
+ $this->assertFalse( IPv6::isULA( '::1' ) );
+ }
}