Skip to content

Commit d2ee65c

Browse files
committed
1.0.2
1 parent 0720e1c commit d2ee65c

6 files changed

Lines changed: 21 additions & 34 deletions

File tree

README.rst

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ As a result, unless a bug is present only in the PHP version, pull requests
1313
are unlikely to be accepted unless they are themselves direct transliterations
1414
of bugfixes in the Python version.
1515

16-
**This port has been marked version 1.0.0**. It is based on the Python version at
17-
commit `3e0b80a32c8478c076171e0cffcf754141a9950d
18-
<https://github.com/docopt/docopt/commit/3e0b80a32c8478c076171e0cffcf754141a9950d>`_
16+
**This port has been marked version 1.0**. It is based on the Python version at
17+
commit `463d780a698cbacb1cf5590ae849b8f890baf25d
18+
<https://github.com/docopt/docopt/commit/463d780a698cbacb1cf5590ae849b8f890baf25d>`_
1919
(labelled **0.6.1**).
2020

2121
It has been quite stable for a long time and has barely been changed. The Python version
@@ -56,22 +56,22 @@ and instead can write only the help message--*the way you want it*.
5656
<?php
5757
$doc = <<<DOC
5858
Naval Fate.
59-
59+
6060
Usage:
6161
naval_fate.php ship new <name>...
6262
naval_fate.php ship <name> move <x> <y> [--speed=<kn>]
6363
naval_fate.php ship shoot <x> <y>
6464
naval_fate.php mine (set|remove) <x> <y> [--moored | --drifting]
6565
naval_fate.php (-h | --help)
6666
naval_fate.php --version
67-
67+
6868
Options:
6969
-h --help Show this screen.
7070
--version Show version.
7171
--speed=<kn> Speed in knots [default: 10].
7272
--moored Moored (anchored) mine.
7373
--drifting Drifting mine.
74-
74+
7575
DOC;
7676
7777
require('path/to/src/docopt.php');
@@ -92,21 +92,9 @@ information in it to make a parser*.
9292
Installation
9393
======================================================================
9494

95-
``docopt.php`` is available on `Packagist <http://packagist.org/packages/docopt/docopt>`_.
96-
Create a ``composer.json`` file for your project
97-
98-
.. code-block:: javascript
99-
100-
{
101-
"require": {
102-
"docopt/docopt": "1.0.0"
103-
}
104-
}
105-
106-
Install using composer::
107-
108-
php composer.phar install
95+
Install ``docopt.php`` using `Composer <http://getcomposer.org>`_::
10996

97+
composer require docopt/docopt
11098

11199
Alternatively, you can just drop ``docopt.php`` file into your project--it is
112100
self-contained. `Get source on github <http://github.com/docopt/docopt.php>`_.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "docopt/docopt",
33
"type": "library",
44
"description": "Port of Python's docopt for PHP 5.3",
5-
"version": "1.0.0",
5+
"version": "1.0.2",
66
"keywords": ["cli","docs"],
77
"homepage": "http://github.com/docopt/docopt.php",
88
"license": "MIT",

examples/any-options.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?php
2+
require __DIR__.'/../src/docopt.php';
23

3-
require(__DIR__.'/../src/docopt.php');
4-
5-
$doc = "
4+
$doc = <<<'DOCOPT'
65
Example of program which uses [options] shortcut in pattern.
76
87
Usage:
@@ -16,8 +15,8 @@
1615
--apply apply changes to database
1716
-q operate in quiet mode
1817

19-
";
18+
DOCOPT;
2019

21-
$result = Docopt\docopt($doc, array('version'=>'1.0.0rc2'));
20+
$result = Docopt::handle($doc, array('version'=>'1.0.0rc2'));
2221
foreach ($result as $k=>$v)
2322
echo $k.': '.json_encode($v).PHP_EOL;

examples/arguments.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?php
2+
require __DIR__.'/../src/docopt.php';
23

3-
require(__DIR__.'/../src/docopt.php');
4-
5-
$doc = "
4+
$doc = <<<'DOCOPT'
65
Process FILE and optionally apply correction to either left-hand side or
76
right-hand side.
87
@@ -21,8 +20,8 @@
2120
--left use left-hand side
2221
--right use right-hand side
2322

24-
";
23+
DOCOPT;
2524

26-
$result = Docopt\docopt($doc, array('version'=>'1.0.0rc2'));
25+
$result = Docopt::handle($doc, array('version'=>'1.0.0rc2'));
2726
foreach ($result as $k=>$v)
2827
echo $k.': '.json_encode($v).PHP_EOL;

py

src/docopt.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,7 @@ function extras($help, $version, $options, $doc)
10351035
class Handler
10361036
{
10371037
public $exit = true;
1038+
public $exitFullUsage = false;
10381039
public $help = true;
10391040
public $optionsFirst = false;
10401041
public $version;
@@ -1059,8 +1060,8 @@ function handle($doc, $argv=null)
10591060
$usage = $usageSections[0];
10601061

10611062
// temp fix until python port provides solution
1062-
ExitException::$usage = $usage;
1063-
1063+
ExitException::$usage = !$this->exitFullUsage ? $usage : $doc;
1064+
10641065
$options = parse_defaults($doc);
10651066

10661067
$formalUse = formal_usage($usage);

0 commit comments

Comments
 (0)