dox Executable Documentation

Print help

Default behaviour

When run the application
Then the output should be 'Available commands: (use "help <command>" for details)' . PHP_EOL . PHP_EOL . 'help -- Prints available commands and their descriptions.'

List commands

Given the command 'CommandWithDescription1' with the body ' /** * A description of that command * can be multi-line. * * Everything after a blank line should not * be included. */ function doExecute() {} '
Given the command 'CommandWithDescription2' with the body ' /** * @param $nothing This is not a description */ function doExecute() {} '
When I run the command 'help'
Then the output should be 'Available commands: (use "help <command>" for details)' . PHP_EOL . PHP_EOL . 'help -- Prints available commands and their descriptions.' . PHP_EOL . 'CommandWithDescription1 -- A description of that command can be multi-line.' . PHP_EOL . 'CommandWithDescription2'

Command details with description

Given the command 'CommandDetailsWithDescription' with the body ' /** * The description of that command. * * Everything after a blank line is * considered detailed description. */ function doExecute() {} '
When I run the command 'help' with the arguments array('CommandDetailsWithDescription')
Then the output should be 'CommandDetailsWithDescription: The description of that command.' . PHP_EOL . PHP_EOL . ' Everything after a blank line is' . PHP_EOL . ' considered detailed description.'

Command details without description

Given the command 'CommandDetailsWithoutDescription' with the body ' function doExecute() {} '
When I run the command 'help' with the arguments array('CommandDetailsWithoutDescription')
Then the output should be 'CommandDetailsWithoutDescription: (No description available)'

Options without doc comment

Given the command 'OptionsWithoutDocComment' with the body ' function doExecute($one, $two, $three) {} '
When I run the command 'help' with the arguments array('OptionsWithoutDocComment')
Then the output should be 'OptionsWithoutDocComment: (No description available)'

Options without descriptions

Given the command 'OptionsWithoutDescriptions' with the body ' /** * @param $one * @param $two * @param $three */ function doExecute($one, $two, $three) {} '
When I run the command 'help' with the arguments array('OptionsWithoutDescriptions')
Then the output should be 'OptionsWithoutDescriptions: (No description available)' . PHP_EOL . PHP_EOL . 'Valid options:' . PHP_EOL . ' --one' . PHP_EOL . ' --two' . PHP_EOL . ' --three'

Undocumented options

Given the command 'UndocumentedOptions' with the body ' /** * @param $one * @param $three [] */ function doExecute($one, $two, $three) {} '
When I run the command 'help' with the arguments array('UndocumentedOptions')
Then the output should be 'UndocumentedOptions: (No description available)' . PHP_EOL . PHP_EOL . 'Valid options:' . PHP_EOL . ' --one'

Options with descriptions and types

Given the command 'OptionsWithDescriptionsAndTypes' with the body ' /** * @param $one Just a description * @param boolean $two Description with type * @param $three Class type hint */ function doExecute($one, $two, \\DateTime $three) {} '
When I run the command 'help' with the arguments array('OptionsWithDescriptionsAndTypes')
Then the output should be 'OptionsWithDescriptionsAndTypes: (No description available)' . PHP_EOL . PHP_EOL . 'Valid options:' . PHP_EOL . ' --one: Just a description' . PHP_EOL . ' --two: (boolean) Description with type' . PHP_EOL . ' --three: (DateTime) Class type hint'

Default options

Given the command 'DefaultOptions' with the body ' /** * @param $one * @param boolean $two A description */ function doExecute($one=null, $two=false) {} '
When I run the command 'help' with the arguments array('DefaultOptions')
Then the output should be 'DefaultOptions: (No description available)' . PHP_EOL . PHP_EOL . 'Valid options:' . PHP_EOL . ' --one: (=NULL)' . PHP_EOL . ' --two: (boolean=false) A description'

Flag options

Given the command 'FlagOptions' with the body ' /** * @param $one [o] A description */ function doExecute($one) {} '
When I run the command 'help' with the arguments array('FlagOptions')
Then the output should be 'FlagOptions: (No description available)' . PHP_EOL . PHP_EOL . 'Valid options:' . PHP_EOL . ' --one|-o: A description'