Console_CommandLine
[ class tree: Console_CommandLine ] [ index: Console_CommandLine ] [ all elements ]
Packages:
Console_CommandLine


Classes:
Console_CommandLine
Console_CommandLine_Action
Console_CommandLine_Action_Callback
Console_CommandLine_Action_Counter
Console_CommandLine_Action_Help
Console_CommandLine_Action_Password
Console_CommandLine_Action_StoreArray
Console_CommandLine_Action_StoreFalse
Console_CommandLine_Action_StoreFloat
Console_CommandLine_Action_StoreInt
Console_CommandLine_Action_StoreString
Console_CommandLine_Action_StoreTrue
Console_CommandLine_Action_Version
Console_CommandLine_Argument
Console_CommandLine_Command
Console_CommandLine_Element
Console_CommandLine_Exception
Console_CommandLine_MessageProvider_Default
Console_CommandLine_Option
Console_CommandLine_Outputter_Default
Console_CommandLine_Renderer_Default
Console_CommandLine_Result
Console_CommandLine_XmlParser
Files:
Action.php
Argument.php
Callback.php
Command.php
CommandLine.php
Counter.php
Default.php
Default.php
Default.php
Element.php
ex1.php
ex2.php
Exception.php
Help.php
MessageProvider.php
Option.php
Outputter.php
Password.php
Renderer.php
Result.php
StoreArray.php
StoreFalse.php
StoreFloat.php
StoreInt.php
StoreString.php
StoreTrue.php
Version.php
XmlParser.php

Class: Console_CommandLine_Option

Source Location: /Console_CommandLine-1.0.0/CommandLine/Option.php

Class Overview

Console_CommandLine_Element
 |
 --Console_CommandLine_Option

Class that represent a commandline option.


Author(s):

Version:

  • Release: 1.0.0

Copyright:

  • 2007 David JEAN LOUIS

Variables

Methods



Class Details

[line 42]
Class that represent a commandline option.


[ Top ]


Class Variables

$action = 'StoreString'

[line 68]

The option action, defaults to StoreString.
  • Access: public

Type: int


[ Top ]

$action_params = array()

[line 133]

An associative array of additional params to pass to the class corresponding to the action, this array will also be passed to the callback defined for an action of type Callback, Example:

  1. // for a custom action
  2. $parser->addOption('myoption', array(
  3. 'short_name' => '-m',
  4. 'long_name' => '--myoption',
  5. 'action' => 'MyCustomAction',
  6. 'action_params' => array('foo'=>true, 'bar'=>false)
  7. ));
  8. // if the user type:
  9. // $ <yourprogram> -m spam
  10. // in your MyCustomAction class the execute() method will be called
  11. // with the value 'spam' as first parameter and
  12. // array('foo'=>true, 'bar'=>false) as second parameter

  • Access: public

Type: array


[ Top ]

$argument_optional = false

[line 142]

For options that expect an argument, this property tells the parser if the argument is optional and can be ommited
  • Access: public

Type: boolean


[ Top ]

$callback =

[line 107]

The callback function (or method) to call for an action of type Callback, this can be any callable supported by the php function call_user_func.

Example:

  1. $parser->addOption('myoption', array(
  2. 'short_name' => '-m',
  3. 'long_name' => '--myoption',
  4. 'action' => 'Callback',
  5. 'callback' => 'myCallbackFunction'
  6. ));

  • Access: public

Type: mixed


[ Top ]

$choices = array()

[line 86]

An array of possible values for the option if this array is not empty and the value passed is not in the array an exception is raised.

This only make sense for actions that accept values of course.

  • Access: public

Type: array


[ Top ]

$default =

[line 76]

The default value of the option if not provided on the command line.
  • Access: public

Type: mixed


[ Top ]

$long_name =

[line 60]

The option long name (ex: --verbose).
  • Access: public

Type: string


[ Top ]

$short_name =

[line 52]

The option short name (ex: -v).
  • Access: public

Type: string


[ Top ]



Method Detail

__construct (Constructor) [line 155]

Console_CommandLine_Option __construct( [string $name = null], [array $params = array()])

Constructor.
  • Access: public

Overrides Console_CommandLine_Element::__construct() (Constructor.)

Parameters:

string $name — the name of the element
array $params — an optional array of parameters

[ Top ]

dispatchAction [line 228]

void dispatchAction( mixed $value, object $result, object $parser)

Format the value $value according to the action of the option and update the passed Console_CommandLine_Result object.
  • Access: public

Parameters:

mixed $value — the value to format
object $result — a Console_CommandLine_Result instance
object $parser — a Console_CommandLine instance

[ Top ]

expectsArgument [line 204]

boolean expectsArgument( )

Return true if the option requires one or more argument and false otherwise.
  • Access: public

[ Top ]

toString [line 174]

string toString( )

Return the string representation of the option.
  • Access: public

Overrides Console_CommandLine_Element::toString() (Return the string representation of the argument.)
[ Top ]

validate [line 259]

void validate( )

Validate the option instance.
  • Access: public

Overrides Console_CommandLine_Element::validate() (Validate the option instance.)
[ Top ]


Documentation generated on 2019年3月11日 15:22:17 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.

AltStyle によって変換されたページ (->オリジナル) /