<commit_before>======
Manage
======
------------------------------------------------------------
Command Line Manager + Interactive Shell for Python Projects
------------------------------------------------------------

.. image:: https://img.shields.io/pypi/v/manage.svg
        :target: https://pypi.python.org/pypi/manage

.. image:: https://img.shields.io/travis/rochacbruno/manage.svg
        :target: https://travis-ci.org/rochacbruno/manage

.. image:: https://readthedocs.org/projects/manage/badge/?version=latest
        :target: https://manage.readthedocs.io/en/latest/?badge=latest
        :alt: Documentation Status

.. image:: https://requires.io/github/rochacbruno/manage/requirements.svg?branch=master
        :target: https://requires.io/github/rochacbruno/manage/requirements?branch=master
        :alt: Dependencies


* Free software: ISC license
* Documentation: https://manage.readthedocs.io.


Features
========

With **manage** you add a **command line manager** to your Python project and
also it comes with an interactive shell with iPython support.

All you have to do is **init** your project directory (creating the manage.yml file)

.. code-block:: console

    $ pip install manage
    $ cd /my_project_root_folder
    $ manage init
    creating manage.yml....

The file **manage.yml** describes how **manage** command should discover your app modules and custom commands and also it
defines which objects should be loaded in to the **shell**

The Shell
=========

By default the command :code:`manage shell` is included, it is a simple Python REPL console with some
configurable options.

You can change the banner message to say anything you want, **e.g: "Welcome to my shell!"** and you can also
specify some objects to be automatically imported in to the shell context so when you enter in to the shell you
already have your project's common objects available.

Also you can specify a custom function to run or a string based code block to run, useful to init and configure the objects.

If **ptpython** is installed **manage shell** will load it

If **IPython** is installed **manage shell** loads it

Else will use the **default Python console** including support for autocomplete.

Check the examples in:

https://github.com/rochacbruno/manage/tree/master/examples/


Custom Commands
===============

Sometimes you need to add custom commands in to your project
e.g: A command to add users to your system::

  $ manage create_user --name=Bruno --passwd=<PASSWORD>
  Creating the user...

**manage** has some different ways for you to define custom commands,
you can use **click commands** defined in your project modules,
you can also use **function_commands** defined anywhere in your project,
and if really needed can define **inline_commands** inside the **manage.yml** file

1. Using a custom click_commands module (single file)
-----------------------------------------------------
<commit_msg>add shell example to readme<commit_after>======
Manage
======
------------------------------------------------------------
Command Line Manager + Interactive Shell for Python Projects
------------------------------------------------------------

.. image:: https://img.shields.io/pypi/v/manage.svg
        :target: https://pypi.python.org/pypi/manage

.. image:: https://img.shields.io/travis/rochacbruno/manage.svg
        :target: https://travis-ci.org/rochacbruno/manage

.. image:: https://readthedocs.org/projects/manage/badge/?version=latest
        :target: https://manage.readthedocs.io/en/latest/?badge=latest
        :alt: Documentation Status

.. image:: https://requires.io/github/rochacbruno/manage/requirements.svg?branch=master
        :target: https://requires.io/github/rochacbruno/manage/requirements?branch=master
        :alt: Dependencies


* Free software: ISC license
* Documentation: https://manage.readthedocs.io.


Features
========

With **manage** you add a **command line manager** to your Python project and
also it comes with an interactive shell with iPython support.

All you have to do is **init** your project directory (creating the manage.yml file)

.. code-block:: console

    $ pip install manage
    $ cd /my_project_root_folder
    $ manage init
    creating manage.yml....

The file **manage.yml** describes how **manage** command should discover your app modules and custom commands and also it
defines which objects should be loaded in to the **shell**

The Shell
=========

By default the command :code:`manage shell` is included, it is a simple Python REPL console with some
configurable options.

You can change the banner message to say anything you want, **e.g: "Welcome to my shell!"** and you can also
specify some objects to be automatically imported in to the shell context so when you enter in to the shell you
already have your project's common objects available.

Also you can specify a custom function to run or a string based code block to run, useful to init and configure the objects.

If **ptpython** is installed **manage shell** will load it

If **IPython** is installed **manage shell** loads it

Else will use the **default Python console** including support for autocomplete.

The first thing you can do with **manage** is customizing the objects that will be automatically loaded in to shell,
saving you from importing and initializing a lot of stuff every time you need to play with your app via console.

Edit **manage.yml** with:

.. code-block:: yaml

    project_name: My Awesome Project
    help_text: |
      This is the {project_name} interactive shell!
    shell:
      readline_enabled: true
      banner:
        enabled: true
        message: 'Welcome to {project_name} shell!'
      auto_import:
        display: true
        objects:
          my_system.config.settings:
          my_system.my_module.MyClass:
          my_system.my_module.OtherClass:
            as: NiceClass
          sys.path:
            as: sp
            init:
              insert:
                args:
                  - 0
                  - /path/to/be/added/automatically/to/sys/path
      init_script: |
        from my_system.config import settings
        print("Initializing settings...")
        settings.configure()


Then the above **manage.yaml** will give you a shell like this:

.. code-block:: console

    $ manage shell
    Initializing settings...
    Welcome to My Awesome Project shell!
        Auto imported: ['sp', 'settings', 'MyClass', 'NiceCLass']
    >>>  NiceClass. <tab> # autocomplete enabled


Check more examples in:

https://github.com/rochacbruno/manage/tree/master/examples/


Custom Commands
===============

Sometimes you need to add custom commands in to your project
e.g: A command to add users to your system::

  $ manage create_user --name=Bruno --passwd=<PASSWORD>
  Creating the user...

**manage** has some different ways for you to define custom commands,
you can use **click commands** defined in your project modules,
you can also use **function_commands** defined anywhere in your project,
and if really needed can define **inline_commands** inside the **manage.yml** file

1. Using a custom click_commands module (single file)
-----------------------------------------------------

{'fraction_non_alphanumeric': 0.14562569213732005, 'fraction_numerical': 0.0004152823920265781, 'mean_word_length': 2.8533333333333335, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 9, 'https://': 20, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4243851', 'n_tokens_mistral': 1983, 'n_tokens_neox': 1854, 'n_words': 768}