Skip to content

Latest commit

 

History

History
155 lines (97 loc) · 3.19 KB

api.rst

File metadata and controls

155 lines (97 loc) · 3.19 KB

API Reference

Running functions

.. module:: clize.runner

.. autofunction:: clize.run


.. autoclass:: clize.Clize

.. autoclass:: clize.SubcommandDispatcher

Parser

.. module:: clize.parser

.. autoclass:: CliSignature
   :exclude-members: converter

.. autofunction:: parameter_converter

.. autofunction:: default_converter

.. autofunction:: use_class

.. autofunction:: use_mixin

.. autoclass:: CliBoundArguments
    :no-undoc-members:

.. autoclass:: Parameter
   :show-inheritance:
   :exclude-members: L, I, U, R

.. autoclass:: clize.parser.ParameterWithSourceEquivalent
   :show-inheritance:

.. autoclass:: clize.parser.HelperParameter
   :show-inheritance:

.. autoclass:: clize.parser.ParameterWithValue
   :show-inheritance:

.. autofunction:: value_converter

.. autoclass:: clize.parser.NamedParameter
   :show-inheritance:

.. autoclass:: clize.parser.FlagParameter
   :show-inheritance:

.. autoclass:: clize.parser.OptionParameter
   :show-inheritance:

.. autoclass:: clize.parser.IntOptionParameter
   :show-inheritance:

.. autoclass:: clize.parser.PositionalParameter
   :show-inheritance:

.. autoclass:: clize.parser.MultiParameter
   :show-inheritance:

.. autoclass:: clize.parser.ExtraPosArgsParameter
   :show-inheritance:

.. autoclass:: clize.parser.AppendArguments
   :show-inheritance:

.. autoclass:: clize.parser.IgnoreAllArguments
   :show-inheritance:

.. autoclass:: clize.parser.FallbackCommandParameter
   :show-inheritance:

.. autoclass:: clize.parser.AlternateCommandParameter
   :show-inheritance:


Exceptions

.. currentmodule:: None

An error to be displayed to the user.

If clize.run catches this error, the error will be printed without the associated traceback.

def main():
    raise clize.UserError("an error message")

clize.run(main)
$ python usererror_example.py
usererror_example.py: an error message

You can also specify other exception classes to be caught using clize.run's catch argument. However exceptions not based on ~clize.UserError will not have the command name displayed.

An error related to argument parsing. If clize.run catches this error, the command's usage line will be printed.

def main(i:int):
    if i < 0:
        raise clize.ArgumentError("i must be positive")

clize.run(main)
$ python argumenterror_example.py -- -5
argumenterror_example.py: i must be positive
Usage: argumenterror_example.py i
.. automodule:: clize.errors
   :show-inheritance:
   :no-undoc-members:
   :exclude-members: UserError,ArgumentError


Help generation

.. automodule:: clize.help
   :show-inheritance:
   :members:
   :no-undoc-members:


Compability with older clize releases

.. module:: clize.legacy

.. autofunction:: clize.clize

.. autofunction:: clize.make_flag