Skip to main content

simple CLI framework

Project description

https://img.shields.io/pypi/v/wisepy2.svg

Wisepy2

Since we found that the capabilities/features doesn’t attract people into using wisepy, thus we go to an extreme, making the simplest command line tool for Python, but also capable of covering the regular use cases.

Two examples are given in the root directory of this project.

from wisepy2 import *
import sys


@wise
def add(left: int, right: int):
    """
    add up two numbers.
    """
    print(left + right)
    return 0


if __name__ == '__main__':
    add(sys.argv[1:])
https://raw.githubusercontent.com/Xython/wisepy2/master/example-add2.png

Usage

Wisepy2 converts a function into a command, where following components of python functions correspond to the command components. Here’re the mapping rules:

  • variadic args: a positional argument that accepts variable number of arguments, like nargs="*" in argparse.
  • annotations: an annotation will be transformed to the help doc of an argument. If it’s a type, the argument is automatically converted to the type you expect.
  • default argument: default value will be equivalent to specifying default in argparse.
  • keyword argument: keyword only or postional_or_keyword arguments with default values can be passed by --arg value.
  • arguments that’re annotated bool and have True or False default arguments: these arguments can changed as the opposite of its default value by giving --arg.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for wisepy2, version 1.1.1
Filename, size File type Python version Upload date Hashes
Filename, size wisepy2-1.1.1-py3-none-any.whl (4.0 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page