Abacus is a simple interactive calculator CLI

abacus

Abacus is a simple interactive calculator CLI with support for variables, comparison checks, and math functions

λ ./abacus -h         
abacus - a simple interactive calculator CLI with support for variables, 
comparison checks, and math functions

v1.0.0

Usage: abacus [--no-color] [--precision PRECISION] [--eval EVAL]

Options:
  --no-color, -n         disable color in output [default: false]
  --precision PRECISION, -p PRECISION
                         precision for calculations [default: 64]
  --eval EVAL, -e EVAL   evaluate expression and quit
  --help, -h             display this help and exit
  --version              display version and exit

Install

go get -u github.com/viktordanov/abacus

Features

  • History of expressions and Tab completion of all math functions and defined variables
  • All common operations
    > 1+1
    2
    > 1-20
    -19
    > 5^0 / 20
    0.05
    > 2**(2+5)
    128
    
  • Variables
    > d = 12.5
    12.5
    > d * 5 + 5
    67.5
    > a * 5 + 5
    5
    
    Note: Undefined variables are equal to 0
  • Comparisons <, ==, >, <=, >=
    > pi > phi
    true
    > 10 <=10
    true
    > 2 == 0
    false
    
  • E, Pi, Phi
    > e
    2.7182818284590450907955982984276
    > pi
    3.1415926535897931159979634685442
    > phi
    1.6180339887498949025257388711907
    
  • Single arity functions:
    • sqrt
    • ln
    • floor
    • ceil
    • exp
    • sin
    • cos
    • tan
    • round
  • Two arity functions:
    • round (number, digits of precision)
    > round(1.123456789,4)
    1.123
    
    • log (number, base)
    > log(16,4)
    2
    
    • min, max
    > d = 10
    10 
    > min(d,4)
    4
    > max(d,4)
    10
    

Reserved names

  • quit – If a query includes quit, the program will terminate and the query will not be saved to the history file
  • The constants e, pi, and phi

TODO

  • Add full feature list
  • Write tests
    • Base tests
    • Simple benchmark of a complicated expression
    • Improve tests
  • Refactor to depend less on other packages
  • Implement most single arity functions with *big.Float for improved precision
Owner
Viktor Danov
A web dev studying in Vienna, Austria. Go, TS/JS, React ⚛, C++, and a few others; devout tea and soup enthusiast 🍂🍃🍵
Viktor Danov
Similar Resources

A golang library for building interactive prompts with full support for windows and posix terminals.

A golang library for building interactive prompts with full support for windows and posix terminals.

Survey A library for building interactive prompts on terminals supporting ANSI escape sequences. package main import ( "fmt" "github.com/Alec

Jan 6, 2023

Interactive prompt for command-line applications

Interactive prompt for command-line applications

promptui Interactive prompt for command-line applications. We built Promptui because we wanted to make it easy and fun to explore cloud services with

Jan 8, 2023

Interactive prompt to set and push a semver tag

Interactive prompt to set and push a semver tag

cutver For when you know what version to tag, and you want to cut a release in the annotated tag format. Installation go install github.com/roryq/cutv

Nov 15, 2022

An interactive command-line tool to manage your environments

An interactive command-line tool to manage your environments

goto An interactive command-line tool to manage your environments Overview You always need to login to some Linux machine or connect to a MySQL instan

Jul 11, 2022

The missing git branch --interactive

git branch-i I got cross that there's no git branch --interactive, so I made this. It's a very (very) simple curses-mode git branch/git checkout alter

Nov 2, 2022

An interactive shell for go application

goshell An interactive shell for go application in normal mode ctrl-c break exec

Dec 15, 2022

News-parser-cli - Simple CLI which allows you to receive news depending on the parameters passed to it

News-parser-cli - Simple CLI which allows you to receive news depending on the parameters passed to it

news-parser-cli Simple CLI which allows you to receive news depending on the par

Jan 4, 2022

Elegant CLI wrapper for kubeseal CLI

Overview This is a wrapper CLI ofkubeseal CLI, specifically the raw mode. If you just need to encrypt your secret on RAW mode, this CLI will be the ea

Jan 8, 2022

CLI to run a docker image with R. CLI built using cobra library in go.

CLI  to run a docker image with R. CLI built using cobra library in go.

BlueBeak Installation Guide Task 1: Building the CLI The directory structure looks like Fastest process: 1)cd into bbtools 2)cd into bbtools/bin 3)I h

Dec 20, 2021
Comments
  • Fix line close

    Fix line close

    When exiting abacus my shell is broken. Entered characters are not displayed and after hitting return the line just stays empty and adds another input prompt at the end. I'm having bash 5.0.17.

    The line.Close() does not seem to get evalated correctly. If I add it into the the goodbye.Regsiter call the problem disappears. You may probably have a better fix for that. Please review. Thanks.

    Sorry about the changing import line. My go linter does this automatically.

  • Add create history file if it does not exist already

    Add create history file if it does not exist already

    Tried abacus and got an error on first start open /home/ole/.abacus_history: no such file or directory. Maybe it is a good idea to create the history file automatically if it does not exist.

Related tags
Build an interactive CLI application with Go, Cobra and promptui. Video tutorial available on the Div Rhino YouTube channel.

Build an interactive CLI app with Go, Cobra and promptui Text tutorial: https://divrhino.com/articles/build-interactive-cli-app-with-go-cobra-promptui

Dec 8, 2022
Interactive CLI helper for creating git branches with JIRA Links and some text

bb (better-branch) Interactive CLI helper for creating git branches with JIRA Links and some text Still in development? Yes How it works? This tiny ut

Aug 18, 2022
Interactive cli tool for HTTP inspection
Interactive cli tool for HTTP inspection

Wuzz command line arguments are similar to cURL's arguments, so it can be used to inspect/modify requests copied from the browser's network inspector with the "copy as cURL" feature.

Dec 27, 2022
This tool is a CLI-interactive tool for TA who use eeclass platform

NTHU eeclass TA helper. This tool is a CLI-interactive tool for TA who use eeclass platform. It helps TA to download all the submitted homework, and use CSV to record the score and comment, and upload CSV score directly to the eeclass platform with just 2 Enter key!

Dec 11, 2021
🧨 Interactive Process Killer CLI made with Go!
🧨 Interactive Process Killer CLI made with Go!

proc-manager is an interactive CLI to kill processes made with Go, currently supports Linux, Mac OS X, Solaris, and Windows.

Dec 2, 2022
Generate an interactive, autocompleting shell for any Cobra CLI
Generate an interactive, autocompleting shell for any Cobra CLI

cobra-shell Description Leverages the Cobra completion API to generate an interactive shell for any Cobra CLI, powered by go-prompt. On-the-fly autoco

Dec 19, 2022
🔥 [WIP] Interactive Jira Command Line
🔥 [WIP] Interactive Jira Command Line

JiraCLI Interactive Jira CLI ?? This project is still a work in progress ?? This tool mostly focuses on issue search and navigation at the moment. How

Jan 4, 2023
Building powerful interactive prompts in Go, inspired by python-prompt-toolkit.
Building powerful interactive prompts in Go, inspired by python-prompt-toolkit.

go-prompt A library for building powerful interactive prompts inspired by python-prompt-toolkit, making it easier to build cross-platform command line

Jan 3, 2023
Simplistic interactive filtering tool
Simplistic interactive filtering tool

peco Simplistic interactive filtering tool NOTE: If you are viewing this on GitHub, this document refers to the state of peco in whatever current bran

Dec 30, 2022
Terminal UI library with rich, interactive widgets — written in Golang
Terminal UI library with rich, interactive widgets — written in Golang

Rich Interactive Widgets for Terminal UIs This Go package provides commonly needed components for terminal based user interfaces. Among these componen

Jan 7, 2023