Skip to main content

The hackable dependency injection framework

Project description

logos_cdi

LogosCDI is a dependency injection tool that allows you to create extensible and maintainable applications

How to install

pip install logos_cdi

Basic usage

First you need to create an object of the Application class

from logos_cdi.application import Application

app = Application(
    modules=[

    ]
)

You may want to use some modules to improve productivity

from logos_cdi.application import Application
from logos_cdi.command import Commands

app = Application(
    modules=[
        Commands()
    ]
)

The Commands Module gives you a basis for creating commands to be executed in the terminal.

You can call it with:

$ logos
usage: logos [--app-url APP_URL] {} ...
logos: error: the following arguments are required: command

Create your own modules with commands

from logos_cdi.command import Commands, AbstractCommand, CommandModule

class TestCommand(AbstractCommand):

    def define_arguments(self, argument_parser):
        argument_parser.add_argument('--name', default='Anonymous')
        return super().define_arguments(argument_parser)

    def execute(self):
        return print('Hello', self.arguments.name)

class Tests(CommandModule, BaseModule):

    def define_commands(self):
        return {
            'test': Service(
                class_path='test_module.TestCommand',
                parameters={}
            )
        }

Add to your application

from logos_cdi.application import Application
from logos_cdi.command import Commands
from test_module import Tests

app = Application(
    modules=[
        Commands(),
        Tests()
    ]
)
$ logos
usage: logos [--app-url APP_URL] {test} ...
logos: error: the following arguments are required: command

$ logos test --help
usage: logos test [-h] [--name NAME]

options:
  -h, --help   show this help message and exit
  --name NAME

$ logos test
Hello Anonymous

$ logo test --name=foo
Hello foo

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logos_cdi-1.0.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logos_cdi-1.0.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file logos_cdi-1.0.0.tar.gz.

File metadata

  • Download URL: logos_cdi-1.0.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.21

File hashes

Hashes for logos_cdi-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e863d461c7cfc90bab467cc79ff92fc2532067e67861b366e154fb36f57039c0
MD5 e3ce2c39c649d041e8d0dd43f8784aef
BLAKE2b-256 e97196947155b25a3f5f13bd494a456e3fffa48640f60be51aecd312991d5928

See more details on using hashes here.

File details

Details for the file logos_cdi-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: logos_cdi-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.21

File hashes

Hashes for logos_cdi-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 70c63a0981a10259db7692e0698306ae821bcb4fcd8d8f95d5813f067fe10247
MD5 74b8532838838057512e6c6190b0d1ee
BLAKE2b-256 e806fc23dd87fea76fe72f350007beee3ea644b9d2b21444112077e4f8a807a2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page