diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-20 21:55:57 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-20 21:55:57 +0200 |
| commit | 15b87ea17d96856d3ed9f2dbfbc80343b01b78df (patch) | |
| tree | cc5b1fbbb722ddbab49450d308d6945d99f3c01c /cmd | |
| parent | 9a282b74a179517c009f855c14d3fa63ad805871 (diff) | |
cmd/perc/main.go: try RPN parsing before percentage calculation in command mode
- Bare expressions like '1 2 +' now work without 'calc' prefix
- Assignment format 'name value =' requires 'calc' subcommand prefix
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/perc/main.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/cmd/perc/main.go b/cmd/perc/main.go index d33593c..2cee268 100644 --- a/cmd/perc/main.go +++ b/cmd/perc/main.go @@ -56,6 +56,13 @@ func runCommand(args []string) (string, error) { } input := strings.Join(args[1:], " ") + + // Try RPN parsing first (for bare RPN expressions like "3 4 +") + if rpnResult, rpnErr := runRPN(input); rpnErr == nil { + return rpnResult, nil + } + + // Fall back to percentage calculation result, err := calculator.Parse(input) if err != nil { return "", err |
