2 releases
0.0.1-beta.2 | Mar 18, 2023 |
---|---|
0.0.1-beta.1 | Mar 17, 2023 |
#18 in #stateless
12KB
75 lines
reply
reply
📩 makes any command-line application a (stateless) REPL.
$ reply 'python | cowsay -f tux -n'
> print("Hello reply📩!")
________________
< Hello reply📩! >
----------------
\
\
.--.
|o_o |
|:_/ |
// \ \
(| | )
/'\_ _/`\
\___)=(___/
>
Read the installation and usage instructions below.
Installation
From source (recommended)
Either clone the repository to your machine and install from it, or install directly from GitHub. Both options require Rust and Cargo to be installed.
# Option 1: cloning and installing from the repository
$ git clone https://github.com/schneiderfelipe/getanswe.rs.git
$ cd getanswe.rs && cargo install reply --path=reply/
# Option 2: installing directly from GitHub
$ cargo install reply --git=https://github.com/schneiderfelipe/getanswe.rs
If you're looking to contribute to the project's development, the first option is the way to go (and thank you for your interest!). However, if you simply want to install the development version, the second option is likely the better choice.
Usage
Using this tool is simple:
$ reply 'python'
>
Whatever you type in the prompt will be fed to the backend command (python
in the example).
The output of the command will be displayed in the terminal.
For example:
$ reply 'python'
> print("Hello " + "python")
Hello python
>
However, there are a few things to keep in mind:
- Only the standard output is captured. If nothing is printed, nothing will be shown.
- The REPL is stateless, which means that there's no memory being carried out. If you define a variable, for example, it won't be available in the next prompt.
Here's an example:
$ reply 'python'
> a = 2 # no output
> print(f"a = {a}") # no memory
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'a' is not defined
Therefore, it's the responsibility of the backend application to
- Print out results to the standard output.
- Implement memory (normally through a file).
Unsafe code usage
This project forbids unsafe code usage.
License: MIT
Dependencies
~11–22MB
~311K SLoC