Skip to content

niko4570/simple-CLI-for-arithmetic-operations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

count_cli

A small arithmetic library + CLI for basic calculations (sum, subtract, multiply, divide) supporting floats.

Quickstart

As a binary (non-interactive):

cargo run -- sum 1.5 2.25
# -> 3.75

cargo run -- multiply 2 3 4
# -> 24

As a library:

[dependencies]
count_cli = "0.1"
use count_cli::ops;
let s = ops::calculate_sum("1.2 3.4");
println!("{}", s);

Interactive mode

Run cargo run with no arguments and follow the prompts.

Example binary

There's a small example binary under examples/cli.rs. Build and run it with:

cargo run --example cli -- 1 2 3
# -> prints sum and product

Notes

  • Input tokens that cannot be parsed as numbers are ignored.
  • Division returns an error message when dividing by zero or on empty input.
  • All calculations use floating-point (f64).

License

Dual-licensed under MIT OR Apache-2.0. See the LICENSE file.

simple-CLI-for-arithmetic-operations

About

A small arithmetic library + CLI for basic calculations (sum, subtract, multiply, divide) supporting floats.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors