PHP 클래스 GetOptionKit\ContinuousOptionParser

app.php [--app-options] [subcommand --subcommand-options] [subcommand --subcommand-options] [subcommand --subcommand-options] [arguments] ContinuousOptionParser is for the process flow: init app options, parse app options while not end if stop at command shift command parse command options else if stop at arguments shift arguments execute current command with the arguments. Example code: subcommand stack $subcommands = array('subcommand1','subcommand2','subcommand3'); different command has its own options $subcommand_specs = array( 'subcommand1' => $cmdspecs, 'subcommand2' => $cmdspecs, 'subcommand3' => $cmdspecs, ); for saved options $subcommand_options = array(); command arguments $arguments = array(); $argv = explode(' ','-v -d -c subcommand1 -a -b -c subcommand2 -c subcommand3 arg1 arg2 arg3'); parse application options first $parser = new ContinuousOptionParser( $appspecs ); $app_options = $parser->parse( $argv ); while( ! $parser->isEnd() ) { if( $parser->getCurrentArgument() == $subcommands[0] ) { $parser->advance(); $subcommand = array_shift( $subcommands ); $parser->setSpecs( $subcommand_specs[$subcommand] ); $subcommand_options[ $subcommand ] = $parser->continueParse(); } else { $arguments[] = $parser->advance(); } }
상속: extends OptionParser
파일 보기 프로젝트 열기: c9s/getoptionkit 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$argv
$index
$length

공개 메소드들

메소드 설명
__construct ( OptionCollection $specs ) * for the constructor , the option specs is application options
advance ( ) : string Return the current argument and advance to the next position.
continueParse ( )
getCurrentArgument ( ) : string Return the current argument that the index pointed to.
isEnd ( )
parse ( array $argv )
startFrom ( $index )

메소드 상세

__construct() 공개 메소드

* for the constructor , the option specs is application options
public __construct ( OptionCollection $specs )
$specs OptionCollection

advance() 공개 메소드

Return the current argument and advance to the next position.
public advance ( ) : string
리턴 string

continueParse() 공개 메소드

public continueParse ( )

getCurrentArgument() 공개 메소드

Return the current argument that the index pointed to.
public getCurrentArgument ( ) : string
리턴 string

isEnd() 공개 메소드

public isEnd ( )

parse() 공개 메소드

public parse ( array $argv )
$argv array

startFrom() 공개 메소드

public startFrom ( $index )

프로퍼티 상세

$argv 공개적으로 프로퍼티

public $argv

$index 공개적으로 프로퍼티

public $index

$length 공개적으로 프로퍼티

public $length