A CLI framework based on asyncio

Overview

asynccli

Latest PyPI version Version status Python 3.5 and 3.6 Latest Travis CI build status Codacy grade Codacy coverage

A CLI framework based on asyncio.

Note

This is still in active development. Things will change. For now, the basic framework is operational. If you are interested in helping out, or would like to see any particular features added, let me know.

Usage

The simplest usage is to just pass in an async function.

import asynccli


async def mycli():
    print("Hello, world.")


if __name__ == '__main__':
    app = asynccli.App(mycli)
    app.run()

It can also be instantiated as a class, as long it has a call method.

import asynccli


class DivisionCalculator(asynccli.CLI):
    numerator = asynccli.Integer(help_text='This is the numerator.')
    denominator = asynccli.Integer()

    async def call(self):
        print(self.first_num / self.second_num)


if __name__ == '__main__':
    app = asynccli.App(DivisionCalculator)
    app.run()

In the DivisionCalculator example above, you would call your script like this:

$ /path/to/script.py 2 3
0.6666666666666666

What if you want to have a tiered CLI with a hierarchy of commands? First, create your command by subclassing CLI as above. Then, wrap the whole thing inside of the TieredCLI class, and pass that to the App.

class Calculator(asynccli.TieredCLI):
    d = DivisionCalculator

if __name__ == '__main__':
    app = asynccli.App(Calculator)
    app.run()

Now, to invoke the script, you have an extra argument to call:

$ /path/to/script.py d 2 3
0.6666666666666666

Installation

pip install asynccli

Requirements

Currently it requires Python 3.5 to make use of async/await. It uses argparse under the hood, and therefore has no dependencies outside of the standard library.

Roadmap

  • Additional Argument types
  • Integration of additional argparse features
  • Add uvloop
  • Better support for help documentation

Testing

You can invoke the test scripts a few different ways:

$ py.test
$ python setup.py test
$ python -m py.test

And, in order to generate the test coverage:

$ coverage run -m py.test

License

MIT

Authors

asynccli was written by Adam Hopkins.

Owner
Adam Hopkins
the brew·mas·ter (noun) /bro͞o ˈmastər/
Adam Hopkins
As easy as /aitch-tee-tee-pie/ 🥧 Modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more. https://twitter.com/httpie

HTTPie: human-friendly CLI HTTP client for the API era HTTPie (pronounced aitch-tee-tee-pie) is a command-line HTTP client. Its goal is to make CLI in

HTTPie 25.4k Dec 30, 2022
CLI tool to develop StarkNet projects written in Cairo

OpenZeppelin Nile ⛵ Navigate your StarkNet projects written in Cairo. Getting started Create a folder for your project and cd into it: mkdir myproject

OpenZeppelin 305 Dec 30, 2022
A command line interface to interact with the Hypixel api allowing the user to get stats, leaderboards, etc

HyConsole is a way to get data on players and leaderboards from the Hypixel Minecraft server from the command line. Keep in mind I have no a

1 Feb 14, 2022
spade is the next-generation networking command line tool.

spade is the next-generation networking command line tool. Say goodbye to the likes of dig, ping and traceroute with more accessible, more informative and prettier output.

Vivaan Verma 5 Jan 28, 2022
PyDropper - pick colors everywhere

PyDropper - pick colors everywhere Downloads Settings PyDropper is an eyedropper

Herman Brunberg 2 Jan 04, 2022
A startpage configured aesthetically with terminal-esque link formatting

Terminal-y Startpage Setup Clone the repository, then make an unformatted.txt file following the specifications in example.txt. Run format.py Open ind

belkarx 13 May 01, 2022
🌈 Lightweight Python package that makes it easy and fast to print terminal messages in colors. 🌈

🌈 Colorist for Python 🌈 Lightweight Python package that makes it easy and fast to print terminal messages in colors. Prerequisites Python 3.9 or hig

Jakob Bagterp 1 Feb 05, 2022
A simple command line virtual operating system, written in python

Virtual operating system A simple virtual operating system written in python. (Under development). Currently, the following commands are supported: Co

B.Jothin kumar 7 Nov 15, 2022
This is an app for creating your own color scheme for Termux!

Termux Terminal Theme Creator [WIP] If you need help on how to use the program, you can either create a GitHub issue or join this temporary Discord se

asxlvm 3 Dec 31, 2022
Module for converting 2D Python lists to fancy ASCII tables. Table2Ascii lets you display pretty tables in the terminal and on Discord.

table2ascii Module for converting 2D Python lists to a fancy ASCII/Unicode tables table2ascii 📥 Installation 🧑‍💻 Usage Convert lists to ASCII table

Jonah Lawrence 40 Jan 03, 2023
Generate an ASCII Art from keyword put in the cli

ascii-art-generator-cli Generate an ASCII Art from keyword put in the cli Install git clone https://github.com/Nathanlauga/ascii-art-generator-cli cd

Nathan Lauga 1 Nov 14, 2021
⚙ A lightweight command line interface library for creating commands.

⚙ A lightweight command line interface library for creating cli commands. About | Installation | Usage | Features | Contributors | License About Next:

Serum 16 Sep 25, 2022
A simple weather tool. I made this as a way for me to learn Python, API, and PyPi packaging.

A simple weather tool. I made this as a way for me to learn Python, API, and PyPi packaging.

Clint E. 105 Dec 31, 2022
A simple web-based SSH client.

Kommander A simple web-based SSH client. It supports: entering SSH login details (including private key and custom ports) and connecting user authenti

KingWaffleIII 2 Jan 01, 2022
A simple CLI productivity tool to quickly display the syntax of a desired piece of code

Iforgor Iforgor is a customisable and easy to use command line tool to manage code samples. It's a good way to quickly get your hand on syntax you don

Solaris 21 Jan 03, 2023
Quickly open any path on your terminal window in your $EDITOR of choice!

Tmux fpp Plugin wrapper around Facebook PathPicker. Quickly open any path on your terminal window in your $EDITOR of choice! Demo Dependencies fpp - F

257 Dec 28, 2022
A helper program to play wordle

A helper program to play wordle

1 Jan 22, 2022
Colors in Terminal - Python Lang

🎨 Colorate - Python 🎨 About Colorate is an Open Source project that makes it easy to use Python color coding in your projects. After downloading the

0110 Henrique 1 Dec 01, 2021
instant coding answers via the command line

howdoi instant coding answers via the command line Sherlock, your neighborhood command-line sloth sleuth. Are you a hack programmer? Do you find yours

Benjamin Gleitzman 9.8k Jan 08, 2023
This is the public repo for the VS Code Extension AT&T i386/IA32 UIUC-ECE391 Syntax Highlighting

AT&T i386 IA32 UIUC ECE391 GCC Highlighter & Snippet & Linter This is the VS Code Extension for UIUC ECE 391, MIT 6.828, and all other AT&T-based i386

Jackgetup 1 Feb 05, 2022