cli2


Namecli2 JSON
Version 2.8.0 PyPI version JSON
download
home_pagehttps://yourlabs.io/oss/cli2
Summaryimage:: https://yourlabs.io/oss/cli2/badges/master/pipeline.svg
upload_time2024-10-03 10:19:39
maintainerNone
docs_urlNone
authorJames Pic
requires_python>=3.6
licenseMIT
keywords cli
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. image:: https://yourlabs.io/oss/cli2/badges/master/pipeline.svg
   :target: https://yourlabs.io/oss/cli2/pipelines
.. image:: https://codecov.io/gh/yourlabs/cli2/branch/master/graph/badge.svg
  :target: https://codecov.io/gh/yourlabs/cli2
.. image:: https://img.shields.io/pypi/v/cli2.svg
   :target: https://pypi.python.org/pypi/cli2

cli2: Dynamic CLI for Python 3
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expose Python functions or objects with a minimalist argument typing style, or
building your own command try during runtime.

`Documentation available on RTFD
<https://cli2.rtfd.io>`_.

Demo
====

cli2 is a little library to build CLIs, which documentation is `available on
RTFD <https://cli2.readthedocs.io/en/latest/>`_, but it comes with its own demo
command that may as well be useful to explore Python libraries and call
functions on the fly.

Because, initially, cli2 was supposed to just bring Python callables on the CLI
without even a single line of code::

    cli2 path.to.your.callable arg1 kwarg1=value

This command was implemented again in this 10th rewrite of the CLI engine
extracted from Playlabs, however this implementation features something pretty
funny: cli2 is a Group subclass which overrides the default Group
implementation based on the first argument passed on the command line.

Basically, when you call ``cli2 path.to.module``, it will load a Group of name
``path.to.module`` which whill load one Command per callable in
``path.to.module``.

When you call ``cli2 path.to.function`` it will execute the function.

As a result, these three commands are strictly equivalent::

    cli2 cli2.test_node.example_function foo=bar
    cli2 cli2.test_node example_function foo=bar

That is because cli2 generates a group with every member of the previous group!

See for yourself with::

    cli2 help cli2.test_node

Or just::

    cli2 cli2.test_node

Because cli2.test_node is not a callable but a module, cli2's cli2 CLI created
a command Group on the fly with the module and added every callable member as
command.

When you call a group on the command line, it displays help by default to drive
the user.

            

Raw data

            {
    "_id": null,
    "home_page": "https://yourlabs.io/oss/cli2",
    "name": "cli2",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "cli",
    "author": "James Pic",
    "author_email": "jamespic@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/47/fc/ff2cf7d4c1d3aa4a8551d49196195810e7a01f49421846b795438bcd75a1/cli2-2.8.0.tar.gz",
    "platform": null,
    "description": ".. image:: https://yourlabs.io/oss/cli2/badges/master/pipeline.svg\n   :target: https://yourlabs.io/oss/cli2/pipelines\n.. image:: https://codecov.io/gh/yourlabs/cli2/branch/master/graph/badge.svg\n  :target: https://codecov.io/gh/yourlabs/cli2\n.. image:: https://img.shields.io/pypi/v/cli2.svg\n   :target: https://pypi.python.org/pypi/cli2\n\ncli2: Dynamic CLI for Python 3\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nExpose Python functions or objects with a minimalist argument typing style, or\nbuilding your own command try during runtime.\n\n`Documentation available on RTFD\n<https://cli2.rtfd.io>`_.\n\nDemo\n====\n\ncli2 is a little library to build CLIs, which documentation is `available on\nRTFD <https://cli2.readthedocs.io/en/latest/>`_, but it comes with its own demo\ncommand that may as well be useful to explore Python libraries and call\nfunctions on the fly.\n\nBecause, initially, cli2 was supposed to just bring Python callables on the CLI\nwithout even a single line of code::\n\n    cli2 path.to.your.callable arg1 kwarg1=value\n\nThis command was implemented again in this 10th rewrite of the CLI engine\nextracted from Playlabs, however this implementation features something pretty\nfunny: cli2 is a Group subclass which overrides the default Group\nimplementation based on the first argument passed on the command line.\n\nBasically, when you call ``cli2 path.to.module``, it will load a Group of name\n``path.to.module`` which whill load one Command per callable in\n``path.to.module``.\n\nWhen you call ``cli2 path.to.function`` it will execute the function.\n\nAs a result, these three commands are strictly equivalent::\n\n    cli2 cli2.test_node.example_function foo=bar\n    cli2 cli2.test_node example_function foo=bar\n\nThat is because cli2 generates a group with every member of the previous group!\n\nSee for yourself with::\n\n    cli2 help cli2.test_node\n\nOr just::\n\n    cli2 cli2.test_node\n\nBecause cli2.test_node is not a callable but a module, cli2's cli2 CLI created\na command Group on the fly with the module and added every callable member as\ncommand.\n\nWhen you call a group on the command line, it displays help by default to drive\nthe user.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "image:: https://yourlabs.io/oss/cli2/badges/master/pipeline.svg",
    "version": "2.8.0",
    "project_urls": {
        "Homepage": "https://yourlabs.io/oss/cli2"
    },
    "split_keywords": [
        "cli"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "47fcff2cf7d4c1d3aa4a8551d49196195810e7a01f49421846b795438bcd75a1",
                "md5": "4b6c038e71dfd6f0e54eb39b47cff477",
                "sha256": "47b6955686cb8d3a95ebaa8ff0d9f0acbbbb9ec94546377171c2c4f3969feddc"
            },
            "downloads": -1,
            "filename": "cli2-2.8.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4b6c038e71dfd6f0e54eb39b47cff477",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 21286,
            "upload_time": "2024-10-03T10:19:39",
            "upload_time_iso_8601": "2024-10-03T10:19:39.370365Z",
            "url": "https://files.pythonhosted.org/packages/47/fc/ff2cf7d4c1d3aa4a8551d49196195810e7a01f49421846b795438bcd75a1/cli2-2.8.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-03 10:19:39",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "cli2"
}
        
Elapsed time: 0.48053s