Git Product home page Git Product logo

pymobilesuit's Introduction

This repository permanently moved to HIT-ReFreSH.

PlasticMetal.(Py)MobileSuit

PyPI GitHub GitHub last commit GitHub Workflow Status PyPI - Format PyPI - Wheel PyPI - Implementation GitHub repo size GitHub code size

View at PyPI

MobileSuit provides an easy way to build Console App quickly. For python.

This is the python version of PlasticMetal.MobileSuit (For .NET).

Setup

pip install PyMobileSuit

Usage

There is a quite simple example:

# [Import and Configure]
from PlasticMetal.MobileSuit import SuitInfo, Suit, SuitIgnore, SuitAlias, SuitConfig
SuitConfig.LOCALE = 'en'

# [Write Application Class]
class Hello(object):
    def __init__(self):
        pass

    @SuitInfo("hello")
    def instance_func(self):
        print("this is instance function")

    @SuitInfo("async")
    @SuitAlias("async")
    async def async_func(self):
        print("this is async func")

    @SuitInfo("helo")
    def func_with_arg(self, name: str):
        print(f"this is async func {name}")

    @SuitIgnore
    def ignored_func(self):
        print("this is func1")

# [Quick Start App]
Suit.QuickStart4BitPowerLine(Hello)
# Suit.QuickStart
# Suit.QuickStartPowerLine

# > type `help` after the prompt.

And this is the result:

Import and Configure

from PlasticMetal.MobileSuit import SuitInfo, Suit, SuitIgnore, SuitAlias, SuitConfig is ALL YOU NEED normally.

There are two configurations for PyMobileSuit:

  • LOCALE: en or zh to set language.
  • THROW: To determine whether Exceptions caught from Application methods should be thrown. To debug your application, you may need to set THROW=Ture

Write Application Class

Free to create your application class, write normal or asynchronous methods with or without parameters. Three basic decorators are available for your application methods:

  • @SuitInfo(expr: str, resourceType=None): expr is the description of the command shown in helpcommand's output by default. If you also set resourceType, getattr(resourceType,expr) will be the description.
  • @SuitAlias(alias: str): Add aliases to the command besides the method name
  • @SuitIgnore: Suppose the method is not a command.

Quick Start App

Use Suit.<QuickStartMethod>(<Your Class>) to quickly start the application. There are three built-in QuickStartMethod implementations:

  • Suit.QuickStart: Plain-text IO without powerline.
  • Suit.QuickStartPowerLine: True color Powerline supported IO.
  • Suit.QuickStart4BitPowerLine: ConsoleColor Powerline supported IO.

Normally, you should use Suit.QuickStart or Suit.QuickStart4BitPowerLine.

Notice

Although MobileSuit is easy to use, its features are very comprehensive, so I haven't had the time to write complete documentation.

The current version of PyMobileSuit is migrated from C # using ChatGPT and manual rather than rewritten so that it might be buggy, and that's why I had not published it on the pypi.

KNOWN bugs (2023.7.21)

  • Methods with args cannot be called as expected

pymobilesuit's People

Contributors

ferdinandsu avatar

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.