Source

units / cmd / main.go

package main

import (
	"fmt"
	"os"

	"../../units"
)

func math(in string) {
	out, err := units.Parse(in)
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error:", err)
	} else {
		fmt.Println(out)
	}
}

func main() {
	if len(os.Args) > 1 {
		math(os.Args[1])
		return
	}

	var line string
	fmt.Print("> ")
	_, err := fmt.Scanln(&line)
	for err == nil {
		math(line)
		fmt.Print("> ")
		_, err = fmt.Scanln(&line)
	}

}