Skip to content

Commit

Permalink
Added a parameter reference.
Browse files Browse the repository at this point in the history
  • Loading branch information
epsy committed Feb 6, 2015
1 parent e656129 commit 1747453
Show file tree
Hide file tree
Showing 6 changed files with 622 additions and 9 deletions.
16 changes: 9 additions & 7 deletions clize/extra/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ def unsatisfied(self, ba):


def multi(min=0, max=None):
"""For option parameters, allows the parameter to be repeated on the
command-line with an optional minimum or maximum. For ``*args``-like
parameters, just adds the optional bounds.
.. literalinclude:: /../examples/extra/multi.py
:lines: 6-14
"""

return parser.use_class(
named=MultiOptionParameter, varargs=parser.ExtraPosArgsParameter,
kwargs={
Expand Down Expand Up @@ -383,13 +391,7 @@ def argument_decorator(f):
to qualify another.
.. literalinclude:: /../examples/extra/argdeco.py
:lines:5-25
::
$ python argdeco.py abc -c def ghi
abc DEF ghi
:lines: 5-25
"""
return parser.use_mixin(
DecoratedArgumentParameter, kwargs={'decorator': f})
2 changes: 2 additions & 0 deletions clize/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class Parameter(object):
processed as positional."""

I = IGNORE = ParameterFlag('IGNORE')
"""Annotate a parameter with this and it will be dropped from the
resulting CLI signature."""

U = UNDOCUMENTED = ParameterFlag('UNDOCUMENTED')
"""Parameters annotated with this will be omitted from the
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Contents
multicommands
compositing
packaging
moreparams
params
newparams
api
upgrade
Expand Down
12 changes: 12 additions & 0 deletions docs/newparams.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
.. module:: clize.parser


.. _extending parser:

Extending the parser
====================


.. _parser overview:

Execution overview
------------------

Expand All @@ -23,6 +29,8 @@ Execution overview
prints it.


.. _parameter conversion:

Parameter conversion
--------------------

Expand Down Expand Up @@ -77,6 +85,8 @@ The default parameter converter works as follows:
handle it.


.. _parser description:

The argument parser
-------------------

Expand Down Expand Up @@ -105,6 +115,8 @@ and `~.CliBoundArguments.skip` can also be modified to change the ongoing
argument reading process.


.. _new param example:

Example: Creating a parameter class for specifying log levels
-------------------------------------------------------------

Expand Down

0 comments on commit 1747453

Please sign in to comment.