Giter Club home page Giter Club logo

malt's Introduction

Malt

a toolset for command-driven terminal user interfaces

Motivation

Programs with command-driven interfaces require a lot of boilerplate to handle input validation, error checking, and type casting. Malt abstracts this boilerplate into a small set of easy-to-use functions.

Usage

import malt
options = [
    'spam',
    'eggs i:count s:style=scrambled',
    'sausages b:spicy=False',
]
while True:
    response = malt.offer(options)
    if response.head == 'spam':
        print('spam, spam, spam, spam')
    elif response.head == 'eggs':
        print((response.style+' eggs ') * response.count)
    elif response.head == 'sausages':
        if response.spicy:
            print("!!!SAUSAGE!!!")
        else:
            print('sausage')
    else:
        pass
> spam
spam, spam, spam, spam
> eggs 2
scrambled eggs scrambled eggs
> eggs 2 style="over easy"
over easy eggs over easy eggs
> sausage
sausage
> sausage spicy=True
!!!SAUSAGE!!!
> potatoes
[malt] unknown command

Installation

Github

$ git clone https://github.com/anavros/malt.git malt
$ cd malt
$ pip3 install .

PyPi

TODO: upload to pypi

malt's People

Contributors

anavros avatar

Watchers

James Cloos avatar  avatar

malt's Issues

include a suite of unit tests

Even though almost all of the functions in malt are interface-based and therefore a pain to test, we need to test as much as we reasonably can anyway.

implement multi-platform support

Initially, I only want to get it to run normally in the console, with normal python3 environments; but later on, I want to be able to create a standalone executable in its own window. We would need to find a way to get the program to run without using the python interpreter--purely because some users may not have or want to download python--which I believe is possible. I know the default console on windows is a big pain as well and I would like to provide an option to not use that. I'm imagining a separate, larger version of malt, maybe called gmalt, that provides the same api, but in a small window instead.

write usage documentation

A few of the functions are noted currently, but there is no comprehensive documentation and no usage instructions. Write instructions, examples, and API details.

Implement command-specific help.

Entering command? as a user should show detailed help for that command. This would also require more information during the creation of commands, i.e. comments.

Print using colors and effects.

Add an option to malt.serve() and malt.log() to color output. Not sure if color will apply to a whole line, or if it will be controlled more finely.

Enable tab-completion of commands.

This is going to do with readline somehow. But entering a partial command as a user, as comm... and hitting tab should auto-complete that command. If there are ambiguities, cycle through each option one by one. Ideally, allow completion for any user command that has a known set of options, e.g.:

options = [
    "pick |spam|eggs|ham|:breakfast",
]
#> pick sp... --> pick spam

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.