#cli #bc #rust

bin+lib dntk

Command line’s multi-platform interactive calculator, GNU bc wrapper

28 stable releases

✓ Uses Rust 2018 edition

2.1.18 Jul 11, 2019
2.1.16 Jun 6, 2019
2.1.7 May 31, 2019

#56 in Command line utilities

Download history 272/week @ 2019-06-21 88/week @ 2019-06-28 141/week @ 2019-07-05 7/week @ 2019-07-12 38/week @ 2019-07-19 33/week @ 2019-07-26 88/week @ 2019-08-02 62/week @ 2019-08-09 138/week @ 2019-08-16 167/week @ 2019-08-23 198/week @ 2019-08-30 86/week @ 2019-09-06 59/week @ 2019-09-13 223/week @ 2019-09-20 57/week @ 2019-09-27

336 downloads per month

MIT license

62KB
1K SLoC

dntk

Travis CI v2.1.18 crates docker license platform

dntk is command line's multi-platform Interactive calculator, GNU bc wrapper.
gjf

✔︎ dntk means calculator in a japanese.
✔︎ dntk is gnu bc wrapper. so, syntax is equal to gnu bc. learn syntax more
✔︎ dntk is a NATIVE The Rust Programming Language application.
✔︎ dntk can move cursor, can delete char, can refresh buffer.
✔︎ dntk write color means,

color means
cyan can caluclate & can output
megenta can't caluclate, can't output
yellow danger input char, output warning
green clean buffer message

Current dntk's version: v2.1.18

Download Page: https://github.com/nnao45/dntk/releases/latest

Platform

dntk support multi-platform 😊 mac, linux, freebsd, and windows!!!

  • i686-osx
  • x86_64-osx
  • i686-linux
  • x86_64-linux
  • i686-windows
  • x86_64-windows
  • i686-freebsd
  • x86_64-freebsd

Install

Mac

$ brew install nnao45/dntk/dntk

Linux

$ wget https://github.com/nnao45/dntk/releases/download/v2.1.18/dntk-v2.1.18-x86_64-unknown-linux-musl.zip
$ unzip dntk-v2.1.18-x86_64-unknown-linux-musl.zip

Windows

$ wget https://github.com/nnao45/dntk/releases/download/v2.1.18/dntk-v2.1.18-x86_64-pc-windows-msvc.zip
$ unzip dntk-v2.1.18-x86_64-pc-windows-msvc.zip

FreeBSD

$ wget https://github.com/nnao45/dntk/releases/download/v2.1.18/dntk-v2.1.18-x86_64-unknown-freebsd.zip
$ unzip dntk-v2.1.18-x86_64-unknown-freebsd.zip

Cargo

$ cargo install dntk

zplug

$ zplug 'nnao45/dntk', as:command, from:gh-r

Docker

Can use dntk docker image,
Look!! Very light weight!!🚀

$ docker images nnao45/dntk
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nnao45/dntk         latest              3a37b5d989b5        2 hours ago         10.5MB

And run,

$ docker run -it --rm nnao45/dntk:latest

And...

$ echo 'alias bc=dntk' >> ~/.bashrc
$ echo 'alias bc=dntk' >> ~/.zshrc

All OK!! 😎

Options

❯❯❯ dntk -h
Command line's multi-platform interactive calculator, GNU bc wrapper.

USAGE:
    dntk [FLAGS] [OPTIONS]

FLAGS:
    -h, --help           Prints help information
        --once           Run at only once
    -q, --quiet          No print information message
        --show-limits    Print the local limits enforced by the local version of bc, and quit
    -V, --version        Prints version information
    -w, --white          Set White color in a output

OPTIONS:
    -b, --bc-path <bc_path>    Use a specific bc command path [default: bc]
    -i, --inject <inject>      Pre-run inject statement to the dntk [default: ]
    -s, --scale <scale>        Number of truncated after the decimal point [default: 20]

Windows Support

You may install bc.exe and set PATH.

$ choco install gnuwin
$ # or
$ wget wget https://embedeo.org/ws/command_line/bc_dc_calculator_windows/bc-1.07.1-win32-embedeo-02.zip
$ unzip bc-1.07.1-win32-embedeo-02.zip

gjf

Keybind

Basic Key

key feature
[, ← cursor move to left
], → cursor move to right
0~9 Sendkey this number
Ctrl+C, Enter Finish dntk app
Delete, Backspace Delete current char
@ Clean buffer

Basic Operation

key feature
+ plus
- minus
* multiplication
/ division
^ exponentiation
% remainder

Operation for Logical

key feature
! boolean, relational
| boolean
& boolean
> relational
< relational
= relational

Using Function

you can use under function.

function key feature
(x) () Simple round bracket
sin(x) s() Sin of trigonometric function
cos(x) c() Cosin of trigonometric function
atan(x) a() Tangent of inverse trigonometric function
log(x) l() Logarithm function
exp(x) e() Exponential function
sqrt(x) sqrt() Return square root of the expression function
j(n,x) j() The n-order Bessel function

more detail 👉 https://www.gnu.org/software/bc/manual/html_mono/bc.html

Pipe Use...

$ echo "123 * 2" | dntk
246

behave, like bc ☺️

Have a nice rust hacking days✨😉

Writer & License

dntk was writed by nnao45 (WORK:Infrastructure Engineer, Twitter:@nnao45, MAIL:n4sekai5y@gmail.com).
This software is released under the MIT License, see LICENSE.

Dependencies

~5MB
~90K SLoC