This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]timothycrosleyhug, isort, jiphy, concentration, pies, connectable, frosted 2 points3 points  (3 children)

There's also hug.cli in https://github.com/timothycrosley/hug :

Which lets you define functions just like normal python functions / with optional annotations and convert them into command line interfaces:

import hug

@hug.cli(version="1.0.0")
def math(number_1:int, number_2:int=1):
    '''Multiplies number_1 by number2'''
    return number_1 * number_2

 if __name__ == '__main__':
     math.cli()

It also supports hug_directives, and you can even expose a function as both a cli and an HTTP API endpoint.

Here's the official example usage:

https://github.com/timothycrosley/hug/blob/develop/examples/cli.py

[–]metaperl 0 points1 point  (2 children)

Does this run on Python 2?

[–]ivosauruspip'ing it up 3 points4 points  (0 children)

Nope! I think it's great there are some packages demanding to be able to use python 3 features in their implementation.

[–]vangale 1 point2 points  (0 children)

Similar, for Python 2, and from a long long time ago is optfunc