Skip to main content

Converts CLIs into web forms

Project description

clooey

Command Line Interface (CLI) to a minimal Web UI.

Getting Started

Start by installing clooey using pip.

pip install pip+https://github.com/alvinwan/clooey.git

You can then use the API to convert a script into a form.

import clooey

cli = clooey.parse('sample.py')
html = clooey.generate(cli, clooey.TEMPLATE_FORM) # use default jinja2 template

For customizing your own form HTML, you must use the loop index for input names. The template is provided with one inputs list of strings, which are the prompts provided to input function calls.

Web Demo

See an actual web form by running the following command:

python main.py web sample.py

From left to right, you'll see the launched Flask app with the following form, fill out the form as you would the CLI, then submit the form to see the output.

Screenshot 2024-06-10 at 9 40 48 PM Screenshot 2024-06-10 at 9 41 58 PM Screenshot 2024-06-10 at 9 41 09 PM

CLI Demo

Run the CLI.

python main.py cli sample.py

You'll then see the following output

<form method="post">
    
    <label>Enter your name: </label>
    <input type="text" name="1">
    
    <label>Enter your age: </label>
    <input type="text" name="2">
    
    <label>Enter your city: </label>
    <input type="text" name="3">
    
    <input type="submit" value="submit">
</form>

Next, the script will prompt you for input, as though you were filling out the web form.

Enter your name: Alvin
Enter your age: 1000
Enter your city: Seattle

Finally, the script will execute the Python script with the input values.

Welcome to Seattle, Alvin (1000)!

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

clooey-0.1.0.tar.gz (4.4 kB view hashes)

Uploaded Source

Built Distribution

clooey-0.1.0-py3-none-any.whl (4.6 kB view hashes)

Uploaded Python 3

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