PHP 클래스 MrClay\Cli

Instantiate, add arguments, then call validate(). Afterwards, the user's valid arguments and their values will be available in $cli->values. You may also specify that some arguments be used to provide input/output. By communicating solely through the file pointers provided by openInput()/openOutput(), you can make your app more flexible to end users.
저자: Steve Clay ([email protected])
파일 보기 프로젝트 열기: mrclay/minify

공개 프로퍼티들

프로퍼티 타입 설명
$debug array
$errors validation errors
$isHelpRequest The user wants help info
$moreArgs array
$values option values available after validation. E.g. array( 'a' => false // option was missing ,'b' => true // option was present ,'c' => "Hello" // option had value ,'f' => "/home/user/file" // file path from root ,'f.raw' => "~/file" // file path as given to option )

보호된 프로퍼티들

프로퍼티 타입 설명
$_args MrClay\Cli\Arg[]
$_stdin resource
$_stdout resource

공개 메소드들

메소드 설명
__construct ( boolean $exitIfNoStdin = true )
addArgument ( string $letter, boolean $required, Arg $arg = null ) : Arg
addOptionalArg ( Arg | string $letter ) : Arg
addRequiredArg ( Arg | string $letter ) : Arg
closeInput ( )
closeOutput ( )
getArgument ( string $letter ) : Arg | null
getArgumentsListing ( ) : string
getErrorReport ( ) : string Get a short list of errors with options
getPathArgs ( ) : array Get the full paths of file(s) passed in as unspecified arguments
openInput ( ) : resource Get resource of open input stream. May be STDIN or a file pointer to the file specified by an option with 'STDIN'.
openOutput ( ) : resource Get resource of open output stream. May be STDOUT or a file pointer to the file specified by an option with 'STDOUT'. The file will be truncated to 0 bytes on opening.
validate ( ) * Read and validate options

보호된 메소드들

메소드 설명
addError ( string $letter, string $msg, string $value = null )

메소드 상세

__construct() 공개 메소드

public __construct ( boolean $exitIfNoStdin = true )
$exitIfNoStdin boolean (default true) Exit() if STDIN is not defined

addArgument() 공개 메소드

public addArgument ( string $letter, boolean $required, Arg $arg = null ) : Arg
$letter string
$required boolean
$arg MrClay\Cli\Arg
리턴 MrClay\Cli\Arg

addError() 보호된 메소드

protected addError ( string $letter, string $msg, string $value = null )
$letter string
$msg string
$value string

addOptionalArg() 공개 메소드

public addOptionalArg ( Arg | string $letter ) : Arg
$letter MrClay\Cli\Arg | string
리턴 MrClay\Cli\Arg

addRequiredArg() 공개 메소드

public addRequiredArg ( Arg | string $letter ) : Arg
$letter MrClay\Cli\Arg | string
리턴 MrClay\Cli\Arg

closeInput() 공개 메소드

public closeInput ( )

closeOutput() 공개 메소드

public closeOutput ( )

getArgument() 공개 메소드

public getArgument ( string $letter ) : Arg | null
$letter string
리턴 MrClay\Cli\Arg | null

getArgumentsListing() 공개 메소드

public getArgumentsListing ( ) : string
리턴 string

getErrorReport() 공개 메소드

Get a short list of errors with options
public getErrorReport ( ) : string
리턴 string

getPathArgs() 공개 메소드

Get the full paths of file(s) passed in as unspecified arguments
public getPathArgs ( ) : array
리턴 array

openInput() 공개 메소드

Get resource of open input stream. May be STDIN or a file pointer to the file specified by an option with 'STDIN'.
public openInput ( ) : resource
리턴 resource

openOutput() 공개 메소드

Get resource of open output stream. May be STDOUT or a file pointer to the file specified by an option with 'STDOUT'. The file will be truncated to 0 bytes on opening.
public openOutput ( ) : resource
리턴 resource

validate() 공개 메소드

* Read and validate options
public validate ( )

프로퍼티 상세

$_args 보호되어 있는 프로퍼티

protected Arg[],MrClay\Cli $_args
리턴 MrClay\Cli\Arg[]

$_stdin 보호되어 있는 프로퍼티

protected resource $_stdin
리턴 resource

$_stdout 보호되어 있는 프로퍼티

protected resource $_stdout
리턴 resource

$debug 공개적으로 프로퍼티

public array $debug
리턴 array

$errors 공개적으로 프로퍼티

validation errors
public $errors

$isHelpRequest 공개적으로 프로퍼티

The user wants help info
public $isHelpRequest

$moreArgs 공개적으로 프로퍼티

public array $moreArgs
리턴 array

$values 공개적으로 프로퍼티

option values available after validation. E.g. array( 'a' => false // option was missing ,'b' => true // option was present ,'c' => "Hello" // option had value ,'f' => "/home/user/file" // file path from root ,'f.raw' => "~/file" // file path as given to option )
public $values