Metadata-Version: 2.1
Name: miniflask
Version: 2.2.0
Summary: Small research-oriented hook-based plugin engine.
Home-page: https://github.com/da-h/miniflask
Author: David Hartmann
Maintainer: David Hartmann
License: MIT License
Keywords: miniflask,plugin-engine,plugin-system
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Environment :: Console
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE

MiniFlask
=========
[![python-3 badge](https://img.shields.io/pypi/v/miniflask)](https://pypi.org/project/miniflask/)
[![python-3 badge](https://img.shields.io/pypi/pyversions/miniflask)](https://pypi.org/project/miniflask/)
[![CI build status](https://github.com/da-h/miniflask/workflows/Deploy%20to%20PyPI/badge.svg)](https://github.com/da-h/miniflask/actions?query=workflow%3A%22Deploy+to+PyPI%22)

Miniflask is a **small** research-oriented **plugin**-engine for **python**.
> A long time ago in a galaxy full of plugin-engines ...


Quick Start
-----------

For a quick look into miniflask, just install it using
```bash
pip install miniflask
```

[Read the Documentation](https://da-h.github.io/miniflask)
----------------------

Short Example
-------------


**Module Definition**  
Let's start a new project first by creating a new directory:
```bash
> ls
main.py
modules/
    module1/__init__.py
    module2/__init__.py
    module1/__init__.py
```

Let's define a simple module, `modules/module1/__init__.py`:
```python
def main(state, event):
    print("main event called by module1")

def register(mf):
    mf.register_event('main', main, unique=False)
```

Let's define another module, `modules/module2/__init__.py`:
```python
def main(state, event):
    print("main event called by module2")
    print("it uses a variable var:", state["var"])

def register(mf):
    mf.register_defaults({
        "var": 42
    })
    mf.register_event('main', main, unique=False)
```



Our main.py looks like this:
```python
import miniflask

# initialize miniflask
mf = miniflask.init(module_dirs="./modules")
mf.run()
```


**Usage**:  
Now, we can use our program in the following ways:
```sh
> python main.py
There is nothing to do.
```

```sh
> python main.py module1
main event called by module1
```

```sh
> python main.py module2,module1
main event called by module2
it uses a variable var: 42
main event called by module1
```

```sh
> python main.py module2,module1 --module2.var 9001
main event called by module2
it uses a variable var: 9001
main event called by module1
```


Contributing
---------------

1. [Fork it!](https://github.com/da-h/miniflask/fork)
2. Create your feature branch (`git checkout -b feature/fooBar`)
3. Commit your changes (`git commit -am 'Add some fooBar'`)
4. Push to the branch (`git push origin feature/fooBar`)
5. Create a new Pull Request

License
-------
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT) - See [LICENSE](LICENSE) for details.  


