summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-23 23:07:55 +0200
committerPaul Buetow <paul@buetow.org>2026-03-23 23:07:55 +0200
commit24514ba22f14faff47605c2ca87af009cd244197 (patch)
tree9a2d40de36c3731523a363f974bbf22d310890bb /README.md
parent2f6229e16f99095f44901cd38a83b41deda3c164 (diff)
Update to gt binary name and refactor code quality improvements
- Renamed binary from perc to gt throughout the project - Refactored calculator.Parse to use registration pattern for parsing strategies - Refactored rpn.handleOperator to use operator registry instead of switch statements - Added panic recovery to REPL executor for better resilience - Improved code organization with OperatorRegistry and strategy registration All changes maintain full test compatibility and pass race detection tests.
Diffstat (limited to 'README.md')
-rw-r--r--README.md77
1 files changed, 38 insertions, 39 deletions
diff --git a/README.md b/README.md
index 528d48e..e31a956 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,11 @@
-# perc
+# gt
A simple AI-engineered command-line percentage calculator written in Go.
## Installation
```bash
-go install codeberg.org/snonux/perc/cmd/perc@latest
+go install codeberg.org/snonux/perc/cmd/gt@latest
```
Or using mage:
@@ -16,19 +16,19 @@ mage install
## Usage
-`perc` supports various percentage calculation formats and RPN (Reverse Polish Notation) stack calculations.
+`gt` supports various percentage calculation formats and RPN (Reverse Polish Notation) stack calculations.
### Percentage Calculations
#### Calculate X% of Y
```bash
-perc 20% of 150
+gt 20% of 150
# Output:
# 20.00% of 150.00 = 30.00
# Steps: (20.00 / 100) * 150.00 = 0.20 * 150.00 = 30.00
-perc what is 20% of 150
+gt what is 20% of 150
# Output:
# 20.00% of 150.00 = 30.00
# Steps: (20.00 / 100) * 150.00 = 0.20 * 150.00 = 30.00
@@ -37,7 +37,7 @@ perc what is 20% of 150
#### Find what percentage X is of Y
```bash
-perc 30 is what % of 150
+gt 30 is what % of 150
# Output:
# 30.00 is 20.00% of 150.00
# Steps: (30.00 / 150.00) * 100 = 0.20 * 100 = 20.00%
@@ -46,7 +46,7 @@ perc 30 is what % of 150
#### Find the whole when X is Y% of it
```bash
-perc 30 is 20% of what
+gt 30 is 20% of what
# Output:
# 30.00 is 20.00% of 150.00
# Steps: (30.00 / 20.00) * 100 = 1.50 * 100 = 150.00
@@ -59,78 +59,77 @@ RPN (postfix notation) uses a stack-based approach where operators follow their
#### Basic Arithmetic
```bash
-perc calc 3 4 + # 3 + 4 = 7
+gt 3 4 + # 3 + 4 = 7
# → 7
-perc calc 3 4 - # 3 - 4 = -1
+gt 3 4 - # 3 - 4 = -1
# → -1
-perc calc 5 6 * # 5 * 6 = 30
+gt 5 6 * # 5 * 6 = 30
# → 30
-perc calc 20 4 / # 20 / 4 = 5
+gt 20 4 / # 20 / 4 = 5
# → 5
-perc calc 2 3 ^ # 2^3 = 8
+gt 2 3 ^ # 2^3 = 8
# → 8
-perc calc 10 3 % # 10 % 3 = 1 (modulo)
+gt 10 3 % # 10 % 3 = 1 (modulo)
# → 1
```
#### Expression Chaining
```bash
-perc calc 3 4 + 4 4 - * # (3+4) * (4-4) = 0
+gt 3 4 + 4 4 - * # (3+4) * (4-4) = 0
# → 0
-perc calc 1 2 + 3 * # (1+2) * 3 = 9
+gt 1 2 + 3 * # (1+2) * 3 = 9
# → 9
```
#### Variables
```bash
-perc calc x 5 = # Assign x = 5
+gt x 5 = # Assign x = 5
# → x = 5
-perc calc x 5 = x x + # x + x = 10
+gt x 5 = x x + # x + x = 10
# → 10
-perc calc pi 3.14159 = pi 2 * # 2 * π
+gt pi 3.14159 = pi 2 * # 2 * π
# → 6.28318
-# Note: Variable assignment only works with calc/rpn subcommand:
-# perc calc x 5 = x x + (works)
-# perc x 5 = (won't work in bare mode - use "perc calc x 5 =")
+# Note: Variable assignment works in bare mode (e.g., "gt x 5 =").
+# gt x 5 = x x + (works)
```
#### Variable Management
```bash
-perc calc vars # List all variables
+gt vars # List all variables
# x = 5
-perc calc name d # Delete variable
+gt name d # Delete variable
# Variable removed
-perc calc clear # Clear all variables
+gt clear # Clear all variables
# All variables cleared
```
#### Stack Operations
```bash
-perc calc 1 2 3 dup # Duplicate top value
+gt 1 2 3 dup # Duplicate top value
# → 1 2 3 3
-perc calc 1 2 swap # Swap top two values
+gt 1 2 swap # Swap top two values
# → 2 1
-perc calc 1 2 3 pop # Remove top value
+gt 1 2 3 pop # Remove top value
# → 1 2
-perc calc 1 2 3 show # Show stack without modifying
+gt 1 2 3 show # Show stack without modifying
# → 1 2 3
```
@@ -140,17 +139,17 @@ In REPL mode, RPN operations maintain persistent state between commands. This al
Example REPL session:
```
-perc> rpn 2 3 4 + # Push 2, 3, 4; add last two
+> 2 3 4 + # Push 2, 3, 4; add last two
2 7
-perc> + # Add top two: 2 + 7 = 9
+> + # Add top two: 2 + 7 = 9
9
-perc> 5 * # Multiply by 5: 9 * 5 = 45
+> 5 * # Multiply by 5: 9 * 5 = 45
45
```
To show the current stack without modifying it:
```
-perc> show # Show current stack state
+> show # Show current stack state
45
```
@@ -159,22 +158,22 @@ perc> show # Show current stack state
Hyper operators work on all values on the stack simultaneously:
```bash
-perc calc 1 2 3 4 5 [+] # Sum all: 1+2+3+4+5 = 15
+gt 1 2 3 4 5 [+] # Sum all: 1+2+3+4+5 = 15
# → 15
-perc calc 2 3 4 [*] # Multiply all: 2*3*4 = 24
+gt 2 3 4 [*] # Multiply all: 2*3*4 = 24
# → 24
-perc calc 10 3 2 [-] # 10 - 3 - 2 = 5
+gt 10 3 2 [-] # 10 - 3 - 2 = 5
# → 5
-perc calc 100 5 2 [/] # 100 / 5 / 2 = 10
+gt 100 5 2 [/] # 100 / 5 / 2 = 10
# → 10
-perc calc 2 3 2 [^] # (2^3)^2 = 64
+gt 2 3 2 [^] # (2^3)^2 = 64
# → 64
-perc calc 100 7 3 [%] # 100 % 7 % 3 = 2
+gt 100 7 3 [%] # 100 % 7 % 3 = 2
# → 2
```
@@ -189,7 +188,7 @@ mage build
Or using go directly:
```bash
-go build -o perc ./cmd/perc
+go build -o gt ./cmd/gt
```
## Testing