Add --version flag

This commit is contained in:
Kasper 2021-07-03 02:09:28 +02:00
parent ef4738061e
commit cedc70af3a
2 changed files with 8 additions and 1 deletions

View File

@ -1,6 +1,7 @@
## Next
- Freak out instead of ignoring unexpected arguments
- Add support for non-US "metre" and "litre" spellings
- Add `--version` flag
- Freak out instead of ignoring unexpected arguments
- Fix decimeter parsed as centimeter
## 1.5.1 - 2021 Jun 10

View File

@ -2,6 +2,8 @@ use cpc::eval;
use cpc::units::Unit;
use std::process::exit;
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
/// CLI interface
fn main() {
use std::env;
@ -12,6 +14,10 @@ fn main() {
for arg in args {
match arg.as_str() {
"-v" | "--verbose" => verbose = true,
"--version" => {
println!("{}", VERSION);
exit(0);
},
_ => {
if expression_opt == None {
expression_opt = Some(arg);