
Security News
Bun 1.2.19 Adds Isolated Installs for Better Monorepo Support
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
.. image:: https://img.shields.io/pypi/v/bigcli.svg :target: https://pypi.python.org/pypi/bigcli
.. image:: https://img.shields.io/travis/dudadornelles/bigcli.svg :target: https://travis-ci.org/dudadornelles/bigcli
.. image:: https://readthedocs.org/projects/bigcli/badge/?version=latest :target: https://bigcli.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status
.. image:: https://pyup.io/repos/github/dudadornelles/bigcli/shield.svg :target: https://pyup.io/repos/github/dudadornelles/bigcli/ :alt: Updates
A python framework to write large CLIs. The concept is to automagically derive CLI commands and args based on the object graph of a callable class that implements a CLI command (command name is derived from the class name). It uses argparse_ to create the CLI parser and pinject_ as the Dependency_Injection_ engine. You implement a class - e.g.: DoSomething
- and that generates the name of a subcommand - e.g: do-something
. Then, based on the dependencies of class DoSomething
, we will derive the arguments, e.g.: if DoSomething
depends on Dependency
, which in turn declares __args__ = [bigcli.arg('--option', required=False, help='help')]
(add_argument_ method from argparse_), then command do-something
will have a '--option' argument.
In theory, the auto-generation of arguments should enables and encourage the reuse of internal components for rapid development of consistent and testable rich CLIs, especially those that operate platforms.
.. code-block:: python
#!/usr/bin/env python import bigcli
class Dependency(object):
args = [
bigcli.arg('--option') # short for lambda p: p.add_argument('--option')
]
def __init__(self, args):
self.option = args.option
class Command(object): parent = 'sub-command' depends_on = [Dependency]
def __init__(self, dependency):
self.dependency = dependency
def __call__(self):
print "dependency option: {}".format(self.dependency.option)
if name == "main": bigcli.BigCli(commands=[Command]).execute()
__depends_on__
and __args__
attributes.__parent__ = 'subcommand'
attribute.This package was created with Cookiecutter_ and the audreyr/cookiecutter-pypackage
_ project template.
.. _Dependency_Injection: https://en.wikipedia.org/wiki/Dependency_injection
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _audreyr/cookiecutter-pypackage
: https://github.com/audreyr/cookiecutter-pypackage
.. _add_argument: https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser.add_argument
.. _argparse: https://docs.python.org/2/howto/argparse.html
.. _pinject: https://github.com/google/pinject
FAQs
A python framwork to write large CLIs using dependency injection
We found that bigcli demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
Security News
Popular npm packages like eslint-config-prettier were compromised after a phishing attack stole a maintainer’s token, spreading malicious updates.
Security News
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.