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
A command-line utility that creates projects from cookiecutters (project templates), e.g. Python package projects, VueJS projects.

Cookiecutter A command-line utility that creates projects from cookiecutters (project templates), e.g. creating a Python package project from a Python

18.6k Dec 30, 2022
CLI para o projeto Compilado (Newsletter e Podcast do Código Fonte TV)

Compilado CLI Automatização de tarefas através de linha de comando para a geração de assets para episódios do Compilado, a newsletter e podcast do can

Gabriel Froes 18 Nov 21, 2022
slipit is a command line utility for creating archives with path traversal elements.

slipit is a command line utility for creating archives with path traversal elements. It is basically a successor of the famous evilarc utility with an extended feature set and improved base functiona

usd AG 35 Dec 23, 2022
Generate your name in Ascii modular type art through the terminal

ASCII Name Generator Designed and developed by Eduardo Aire The ASCII Art Name Generator is a simple program that helps you to have a practical Shell/

Eduardo Aire 1 Nov 17, 2021
3DigitDev 29 Jan 17, 2022
Tools hacking termux in the name ant-attack

Hello friends, I am ama.player0000. Web developer, software, Android command line (termux). (1)=Well, ant-attack tool is a tool to attack sites and disable them. (2)=You can use those CCTV servers, s

༺AMA.PLAYER༻ 1 Dec 17, 2021
Interactive Python interpreter for executing commands within Node.js

Python Interactive Interactive Python interpreter for executing commands within Node.js. This module provides a means of using the Python interactive

Louis Lefevre 2 Sep 21, 2022
LSD (Linux Spotify Downloader) is a command line tool for downloading or rather recording content on Spotify.

LSD (Linux Spotify Downloader) is a command line tool for downloading or rather recording content on Spotify.

Jannis Zahn 7 Jun 21, 2022
Tncli - TON smart contract command line interface

Tncli TON smart contract command line interface State Not working, in active dev

Disintar IO 100 Dec 18, 2022
Convert shellcode generated using pe_2_shellcode to cdb format.

pe2shc-to-cdb This tool will convert shellcode generated using pe_to_shellcode to cdb format. Cdb.exe is a LOLBIN which can help evade detection & app

mrd0x 75 Jan 05, 2023
A terminal application for managing images and artifacts in Azure Container Registry.

acr-browser acr-browser is a terminal-based user interface for managing container images and artifacts in Azure Container Registry. 🚀 This project ow

Sam Dobson 5 Jul 30, 2022
An interactive aquarium for your terminal.

sipedon An interactive aquarium for your terminal, written using pytermgui. The project got its name from the Common Watersnake, also known as Nerodia

17 Nov 07, 2022
A clone of the popular online game Wordle

wordle_clone A CLI application for wordle. Description A clone of the popular online game Wordle.

0 Jan 29, 2022
Albert launcher extension for converting units of length, mass, speed, temperature, time, current, luminosity, printing measurements, molecular substance, and more

unit-converter-albert-ext Extension for converting units of length, mass, speed, temperature, time, current, luminosity, printing measurements, molecu

Jonah Lawrence 2 Jan 13, 2022
Output Analyzer for you terminal commands

Output analyzer (OZER) You can specify a few words inside config.yaml file and specify the color you want to be used. installing: Install command usin

Ehsan Shirzadi 1 Oct 21, 2021
Kattis shell for getting examples, testing and submitting.

Kattis shell for getting examples, testing and submitting.

Simon Green Kristensen 15 Sep 30, 2022
A CLI based task manager tool which helps you track your daily task and activity.

CLI based task manager tool This is the simple CLI tool can be helpful in increasing your productivity. More like your todolist. It uses Postgresql as

ritik 1 Jan 19, 2022
CLI tool to view your VIT timetable from terminal anytime!

VITime CLI tool to view your timetable from terminal anytime! Table of contents Preview Installation PyPI Source code Updates Setting up Add timetable

16 Oct 04, 2022
A webmining CLI tool & library for python.

minet is a webmining command line tool & library for python (= 3.6) that can be used to collect and extract data from a large variety of web sources

médialab Sciences Po 165 Dec 17, 2022
CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM

AWS SAM The AWS Serverless Application Model (SAM) is an open-source framework for building serverless applications. It provides shorthand syntax to e

Amazon Web Services 6.2k Jan 08, 2023