Abacus is a simple interactive calculator CLI

Related tags

Command Line abacus
Overview

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
You might also like...
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

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

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

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

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

An interactive shell for go application

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

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

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

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

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.

    opened by triole 4
  • 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.

    opened by triole 2
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
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

Div Rhino Dev 16 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

Eugene Uvarov 3 Aug 18, 2022
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.

Adam Tauber 10.2k 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!

Bo-Wei Chen 1 Dec 11, 2021
🧨 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.

Aykut 24 Dec 2, 2022
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

Brian Strauch 30 Dec 19, 2022
🔥 [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

Ankit Pokhrel 2.3k Jan 4, 2023
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

Masashi Shibata 4.7k Jan 3, 2023
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

null 7.2k Dec 30, 2022
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

rivo 7.8k Jan 7, 2023