Sign in

    formulas-calculator

    A small LunarFormulas-powered formula calculation CLI.

    moonbit
    formula
    calculator
    units
    cli
    Download zip
    Version
    0.1.2
    License
    Apache-2.0
    Last updated
    3 months ago
    Downloads
    54

    #formulas-calculator

    English | 简体中文

    formulas-calculator is a small MoonBit CLI powered by FrozenLemonTee/LunarFormulas and FrozenLemonTee/LunarUnits. It evaluates cataloged physics formulas with unit-bearing inputs.

    #Usage

    During development, run the command through moon:

    moon run cmd/main -- list moon run cmd/main -- show force moon run cmd/main -- calc force --mass "2 kg" --acceleration "3 m/s^2" moon run cmd/main -- calc ohm-voltage --current "2 A" --resistance "3 Ohm"

    Output format:

    moon run cmd/main -- --format si calc force --mass "2 kg" --acceleration "3 m/s^2" moon run cmd/main -- --format latex calc force --mass "2 kg" --acceleration "3 m/s^2"

    #Commands

    • list: list shipped formula names, domains and display equations.
    • show <name>: show a formula's metadata, inputs and output dimension.
    • calc <name> --<input> <quantity>: evaluate a formula with named inputs.

    #Development

    moon test moon info moon fmt

    CommandResult

    pub(all) enum CommandResult {
    Ok(String)
    Err(String)
    } derive(Eq,
    Debug
    )

    InputBinding

    pub struct InputBinding {
    name : String
    value : String
    } derive(Eq,
    Debug
    )

    InputBinding::name

    fn InputBinding::name(self : InputBinding) -> String

    InputBinding::new

    fn InputBinding::new(name : String, value : String) -> InputBinding

    InputBinding::value

    fn InputBinding::value(self : InputBinding) -> String

    parse_format_style

    fn parse_format_style(style : String) ->
    FormatStyle
    ?

    run_calc

    fn run_calc(name : String, bindings : Array[InputBinding], format? : String) -> CommandResult

    run_list

    fn run_list() -> CommandResult

    run_show

    fn run_show(name : String) -> CommandResult