Giter Club home page Giter Club logo

flamewok's Introduction

FlameWok

Very tiny framework to quickly create python terminal apps.

The purpose of this package is to get you rid as much as possible of the tedious part of creating menus, forms, and CLI, and to help to keep the code clean.

Installation

pip install flamewok

Create forms

from flamewok import Form

my_form = Form([
    ("name", "what is your name ?"),
    ("age", "how old are you ?"),
    ])

response = my_form.ask()

Create menus

from flamewok import Menu

menu = Menu()

def hello():
    print("Hi there ! here is the callback hello !")
    menu.ask()

def how():
    print("I'm quite fine, thank you :)")
    menu.ask()

def exit():
    print("Good Bye folks !")
    quit()

menu.add_boxes([
    "\nChoose an option:\n",
    (1, "hello !", hello),
    (2, "how are you ?", how),
    ("x", "exit", exit),
])

menu.ask()

yes, that simple !

Create very quickly a CLI

from flamewok.cli import cli


def main():
    print("main program lanched")


def see(*args):
    """the types are defined in the cli.route"""
    for arg in args:
        print(type(arg), arg)

def multi(*args):
    """the types are not defined in the cli.route, so the args are all str"""
    numbers = [float(arg) for arg in args]
    result = 1
    for num in numbers:
        result *= num
    print(result)


if __name__ == "__main__":
    cli.route(
        "This is a CLI test\n", # this will appear in the help
        ("", main, "Launches the main programm"),
        ("-h", cli.help, "displays this help"),
        ("--help", cli.help, 'Idem'),
        ("see <int:a> <bool:> <str:> <float:>", see, "Show the arguments given in the CLI"),
        ("multi <some_numbers>", multi, "multiply the numbers"),
    )

Fancy titles

from flamewok import big_text
from flamewok import color as c

print(big_text(
        "Example", on="@", off=".", spacing=2, underline=True, color=c.success))

# Output (the color can only be seen in a real terminal):
@@@@@...............................@@...........
@....................................@...........
@......@...@...@@@...@@.@...@@@@.....@.....@@@...
@@@@....@.@.......@..@.@.@..@...@....@....@...@..
@........@.....@@@@..@.@.@..@...@....@....@@@@@..
@.......@.@...@...@..@.@.@..@@@@.....@....@......
@@@@@..@...@...@@@@..@.@.@..@.......@@@....@@@...
.................................................
.................................................
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# or with default settings:

print(big_text("Example"))

# Output:
#####                          ##
#                               #
#     #   #  ###  ## #  ####    #    ###
####   # #      # # # # #   #   #   #   #
#       #    #### # # # #   #   #   #####
#      # #  #   # # # # ####    #   #
##### #   #  #### # # # #      ###   ###

check the wiki to get a better idea of what you can do.

flamewok, docs and exemples are available here: https://github.com/byoso/flamewok

flamewok's People

Contributors

byoso avatar

Stargazers

 avatar

Watchers

 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.