Giter Site home page Giter Site logo

uperations's Introduction

Build Status

Uperations

This Python framework helps you create command line tools with re-usable and sharable commands. View the official documentation at https://www.uperations.com.

A base library is already registered in this project to help you get started fast.

The main components to know are Libraries, Operations and Commands.

  • Operations: An action that has to be executed.
  • Library: A group of operations
  • A command to execute in the terminal to run the Operation

Installation

This project uses python3 and was built using python 3.7.0

git clone https://github.com/baminou/Uperations.git
pip install -r requirements.txt

Create a library

The first thing to do is to create a library to contain your operations.

./main.py base make:library {LIBRARY_NAME}

Register your library to the project

boot.py

The boot() function in the file boot.py is the first function that is called once the program starts. In this function, the Kernel of the program is initialized. The kernel contains the libraries that you need in your project mapped to console command entry point. You can add as many libraries as you need in the Kernel.

from uperations.kernel import Kernel
from uperation_base import Base
from libraries.{YOUR_LIBRARY} import {YOUR_LIBRARY_CLASS}

def boot():
    Kernel.get_instance().set_libraries({
        Base.name(): Base(),
        {YOUR_LIBRARY_CLASS}: {YOUR_LIBRARY_CLASS}()
    })

Kernel

The Kernel is the a singleton that can be accessible in any operations and and that is shared in the entire project.

from uperations.kernel import Kernel

...
kernel = Kernel.get_instance()
...

The Kernel contains the libraries registered in the project

...
kernel.get_libraries()
...

Create an operation

Once you have a library, you can start adding operations.

./main.py base make:operation {LIBRARY_NAME} {OPERATION_NAME}

Add your operation to the library for access in command line

  1. Open ./libraries/{LIBRARY_NAME}/{LIBRARY_NAME}/_init_.py
  2. Import your operation class at the top of the file.
from .{operation_package} import {OperationClass}
  1. Add to the dict operations
@staticmethod
    def operations():
        return {
            ...,
            {command}:{OperationClass}
        }

List all available operations

./main.py base list:operations

Retrieve information about a library

./main.py base {LIBRARY_NAME} -h

Retrieve information about an operation

./main.py base {LIBRARY_NAME} {OPERATION_NAME} -h

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.