Skip to main content

An easy way to build python-CLI App quickly, MobileSuit provides an easy way to build Console App quickly. For python.

Project description

ReFreSH.(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 ReFreSH.MobileSuit (For .NET).

Setup

pip install PyMobileSuit

Usage

There is a quite simple example:

# [Import and Configure]
from ReFreSH.MobileSuit import *

SuitConfig.LOCALE = 'en'  # 'zh' or 'en' (default if not set)


# [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 <name>")
    @SuitAlias("helo")
    def func_with_arg(self, name: str):
        print(f"this is async func {name}")

    @SuitInfo("helos <names>[]")
    @SuitAlias("helos")
    def func_with_list_arg(self, names: list[str]):
        print(f"this is async func {','.join(names)}")

    @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 ReFreSH.MobileSuit import * 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.

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

pymobilesuit-0.1.2.tar.gz (32.8 kB view details)

Uploaded Source

Built Distribution

pymobilesuit-0.1.2-py3-none-any.whl (49.0 kB view details)

Uploaded Python 3

File details

Details for the file pymobilesuit-0.1.2.tar.gz.

File metadata

  • Download URL: pymobilesuit-0.1.2.tar.gz
  • Upload date:
  • Size: 32.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for pymobilesuit-0.1.2.tar.gz
Algorithm Hash digest
SHA256 dcd3329c049dbabbe0ccb098019fbf3937a8498d849feeed26963e9184f0c619
MD5 45f29c3c007f3399e2abd4164df82cf4
BLAKE2b-256 aed2c84b15cfc1d1a9515cd1c2331b37306dc76569e7bf751861863cde30ec17

See more details on using hashes here.

File details

Details for the file pymobilesuit-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pymobilesuit-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ee7c77298d9d80715a4ceabc130fed1ba766988387673236b42c0346881e96a7
MD5 0072885194af40a31732b2f88f391443
BLAKE2b-256 2a6e421bc3bddd8bae0f298a5437eb41e64b4904993c9d6238a555c3d851e37b

See more details on using hashes here.

Supported by

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