GithubHelp home page GithubHelp logo

tokiocli's Introduction

TokioCLI

An Unix CLI based on Tokio

TokioCLI is a very simple async libary allowing to build interactive CLI for UNIX systems.

The following features are supported:

  • Auto-completion with tabulation.
  • Commands history

This library was initially developped for the CLI implentation of acsrs: https://github.com/guillaumepellegrino/acsrs/blob/master/src/acscli.rs

Library documetation is available here: https://docs.rs/tokiocli/latest/tokiocli/index.html

Examples are availabe here: https://github.com/guillaumepellegrino/tokiocli/tree/master/examples

Crate is available at: https://crates.io/crates/tokiocli

TODO:

  • History persistence
  • Ctrl-R ?

tokiocli's People

Contributors

guillaumepellegrino avatar

Stargazers

Lane Biocini avatar

Watchers

 avatar

Forkers

ph4ntomas

tokiocli's Issues

Helper methods for Ctrl+C Support

It would be nice to be able to use ctrl+c to flush the command-line, and re-print the prompt.

The SIGINT (or windows equivalent) can be handled using tokio::signal::ctrl_c. However, this override the signal handler, which should not be done by the library, especially for cases where ctrl+c is not to be used to flush the buffer.
For this reason, signal handling should (in my opinion) be done on the application side, and not by tokiocli.

The way I see it, this could be achieved by having a cancellable getaction, either via an optional parameter, global cli configuration, or an alternate way of calling getaction, which would add this behavior.

This can be implemented in tokiocli via select! macro and `tokio_util::sync::CancellationToken, or by ensuring that get_action is cancellation safe.

The flush mechanism should be kept separate, or at the very least opt-in too.

Splitting the mechanism that pause inputs from the one that empty the internal buffer would also allow one to retrigger a print of the whole line, in case the calling application wants to, e.g. print some log, then restore the line, so the user can resume typing.

I can implement that functionality, but I'd like to know if you have any issue/preferences regarding this, or any input on how to better handle the whole buffer flushing/re-drawing.

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.