cakephp-2.0 > ConsoleOptionParser :: addOption()
ConsoleOptionParser
A
AbstractTransport
AclBehavior
AclComponent
AclInterface
AclNode
AclShell
Aco
AcoAction
ActionsAuthorize
ApcEngine
ApiShell
App
AppController
AppController
AppHelper
AppHelper
AppModel
AppModel
AppShell
Aro
AuthComponent
B
BadRequestException
BakeShell
BakeTask
BaseAuthenticate
BaseAuthorize
BasicAuthenticate
BasicAuthentication
BehaviorCollection
C
Cache
CacheEngine
CacheException
CacheHelper
CacheSession
CakeEmail
CakeErrorController
CakeException
CakeLog
CakeLogException
CakeLogInterface
CakePlugin
CakeRequest
CakeResponse
CakeRoute
CakeSchema
CakeSession
CakeSessionException
CakeSessionHandlerInterface
CakeSocket
ClassRegistry
CommandListShell
Component
ComponentCollection
ConfigReaderInterface
Configure
ConfigureException
ConnectionManager
ConsoleErrorHandler
ConsoleException
ConsoleInput
ConsoleInputArgument
ConsoleInputOption
ConsoleInputSubcommand
ConsoleOptionParser
ConsoleOutput
ConsoleShell
ContainableBehavior
Controller
ControllerAuthorize
ControllerTask
CookieComponent
CrudAuthorize
D
DatabaseSession
DataSource
DbAcl
DbAclSchema
DbConfigTask
DboSource
Debugger
DebugTransport
DigestAuthenticate
DigestAuthentication
Dispatcher
E
EmailComponent
ErrorHandler
ExceptionRenderer
ExtractTask
F
File
FileEngine
FileLog
FixtureTask
Folder
ForbiddenException
FormAuthenticate
FormHelper
H
Helper
HelperCollection
HelpFormatter
HtmlHelper
HttpException
HttpResponse
HttpSocket
I
I18n
I18nModel
i18nSchema
I18nShell
Inflector
IniReader
InternalErrorException
J
JqueryEngineHelper
JsBaseEngineHelper
JsHelper
L
L10n
M
MailTransport
MediaView
MemcacheEngine
MethodNotAllowedException
MissingActionException
MissingBehaviorException
MissingComponentException
MissingConnectionException
MissingControllerException
MissingDatabaseException
MissingDatasourceConfigException
MissingDatasourceException
MissingHelperException
MissingLayoutException
MissingModelException
MissingPluginException
MissingShellException
MissingShellMethodException
MissingTableException
MissingTaskException
MissingTestLoaderException
MissingViewException
Model
ModelBehavior
ModelTask
MootoolsEngineHelper
Multibyte
Mysql
N
NotFoundException
NumberHelper
O
Object
ObjectCollection
P
PagesController
PagesController
PaginatorComponent
PaginatorHelper
Permission
PhpReader
PluginShortRoute
PluginTask
Postgres
PrivateActionException
ProjectTask
PrototypeEngineHelper
R
RedirectRoute
RequestHandlerComponent
Router
RouterException
RssHelper
S
Sanitize
Scaffold
ScaffoldView
SchemaShell
Security
SecurityComponent
SessionComponent
SessionHelper
SessionsSchema
Set
Shell
ShellDispatcher
SmtpTransport
SocketException
Sqlite
Sqlserver
String
T
TaskCollection
TemplateTask
TestsuiteShell
TestTask
TextHelper
ThemeView
TimeHelper
TranslateBehavior
TreeBehavior
U
UnauthorizedException
UpgradeShell
V
Validation
View
ViewTask
W
WincacheEngine
X
XcacheEngine
Xml
XmlException
addOption
Add an option to the option parser. Options allow you to define optional or required
parameters for your console application. Options are defined by the parameters they use.
Method
(ConsoleOptionParser)
public addOption
($name, $options = array())
Parameters
Parameter | Type | Comment | Default |
---|---|---|---|
$name | mixed | required The long name you want to the value to be parsed out as when options are parsed. Will also accept an instance of ConsoleInputOption | |
$options | array | optional An array of parameters that define the behavior of the option | array() |
Return
ConsoleOptionParserComment
Add an option to the option parser. Options allow you to define optional or required
parameters for your console application. Options are defined by the parameters they use.
### Options
- `short` - The single letter variant for this option, leave undefined for none.
- `help` - Help text for this option. Used when generating help for the option.
- `default` - The default value for this option. Defaults are added into the parsed params when the
attached option is not provided or has no value. Using default and boolean together will not work.
are added into the parsed parameters when the option is undefined. Defaults to null.
- `boolean` - The option uses no value, its just a boolean switch. Defaults to false.
If an option is defined as boolean, it will always be added to the parsed params. If no present
it will be false, if present it will be true.
- `choices` A list of valid choices for this option. If left empty all values are valid..
An exception will be raised when parse() encounters an invalid value.
@param mixed $name The long name you want to the value to be parsed out as when options are parsed.
Will also accept an instance of ConsoleInputOption
@param array $options An array of parameters that define the behavior of the option
@return ConsoleOptionParser $this.
parameters for your console application. Options are defined by the parameters they use.
### Options
- `short` - The single letter variant for this option, leave undefined for none.
- `help` - Help text for this option. Used when generating help for the option.
- `default` - The default value for this option. Defaults are added into the parsed params when the
attached option is not provided or has no value. Using default and boolean together will not work.
are added into the parsed parameters when the option is undefined. Defaults to null.
- `boolean` - The option uses no value, its just a boolean switch. Defaults to false.
If an option is defined as boolean, it will always be added to the parsed params. If no present
it will be false, if present it will be true.
- `choices` A list of valid choices for this option. If left empty all values are valid..
An exception will be raised when parse() encounters an invalid value.
@param mixed $name The long name you want to the value to be parsed out as when options are parsed.
Will also accept an instance of ConsoleInputOption
@param array $options An array of parameters that define the behavior of the option
@return ConsoleOptionParser $this.