A command-line calculator built with Rust, designed for quick mathematical evaluations with support for variables and previous answer references.
- Expression evaluation: Evaluate mathematical expressions using standard operators and functions
- Previous answer reference: Use
ansto reference the result from your last calculation - Variable support: Define and use variables in your calculations
- Operator shortcuts: Start expressions with
+,-,*, or/to automatically apply them to the previous answer - Localization support: Use point (
.) comma (,) as decimal separator and semicolon (;) as argument separator - Interactive REPL: Color-coded output with command history
# Clone the repository
git clone https://github.com/yourusername/calcli.git
cd calcli
# Build and run
cargo run --releaseStart the calculator by running the executable. You'll be greeted with an interactive prompt:
calcli – calculator for the command line
Enter a mathematical expression to evaluate it or help for more information.
>>>
>>> 5 + 3
= 8
>>> 2 * pi
= 6.283185307179586
>>> sqrt(16)
= 4
Reference the last result with ans:
>>> 10 + 5
= 15
>>> ans * 2
= 30
>>> + 10
= 40
Define and use variables in your calculations:
>>> x = 5
x = 5
>>> y = x * 2
y = 10
>>> x + y
= 15
Use comma as decimal separator (converted to dot internally):
>>> 3,14 * 2
= 6.28
Use semicolon to separate function arguments:
>>> max(5; 10; 3)
= 10
.qor CTRL-D: Exit the calculator- CTRL-C: (Planned) Copy last result to clipboard
help: (Planned) Display help information
- Allow the use of "ans"
- Allow the definition of variables and their use in expressions
- Add keyboard bindings for number of decimals and scientific notation
- Add the possibility to set the number of decimals with a command line argument
- Include a help command that lists available commands and features
- Implement clipboard support for copying results
- meval - Mathematical expression evaluation
- rustyline - Readline implementation for interactive input
- colored - Terminal color output
MIT License. See LICENSE file for details.
