| Age | Commit message (Collapse) | Author |
|
MetricReader (task ok)
|
|
Extract runCommand() in cmd/gt/main.go into separate helpers
following SRP:
- parseFlags(): extract --log flag parsing
- dispatchInput(): route by arg count/content (version, stdin, args)
- handleNoInput(): TTY→REPL or stdin→parse path
- startREPL(): REPL launch with optional log file
- tryParse(): RPN-first with percentage fallback
runCommand() is now a 3-line orchestrator delegating to parseFlags()
and dispatchInput(). No behavioral change; all tests pass.
|
|
- Fix package doc: reference 'internal' package (not 'cmd/gt/internal')
- Remove unused LogWriter struct and its methods (never instantiated,
repl.RunREPLWithLog passes *os.File directly as io.WriteCloser)
- Remove now-unused 'io' import
- Improve readStdin comment: clarify fallback truncates to 4096 bytes
|
|
Add main_edge_test.go with 12 tests covering:
- Empty args (no input provided)
- Version flag output
- --log flag with RPN calculation
- --log flag with percentage calculation
- --log flag alone (no other args)
- Percentage calculation via CLI
- Invalid percentage expression error
- Multiple CLI args joined as one expression
- Unknown RPN token error
- Mixed args (RPN fallback to percentage)
- RPN power with --log flag
- RPN assignment with --log flag
|
|
Add comparison_test.go with tests for all comparison operators:
- gt (greater than): 3 cases
- lt (less than): 3 cases
- eq/== (equal): 4 cases
- neq/!= (not equal): 4 cases
- gte/lte/>=/<=(greater/less equal): 12 cases
- Metric-aware comparisons: 5 cases (Mbps, km/m, etc.)
- Cross-category error: 2 cases (DataRate vs Time, Speed vs Distance)
- Symbol comparison error: 1 case
|
|
Fix formatting in 12 files to match gofmt standards.
No logical changes.
|
|
- Task 31: Refactor repl tests to remove dependency on package-level singletons
- Task 41: Introduce Calculator interface to decouple REPL from RPN engine
- Task 61: Implement persistent variable store with Save/Load methods
- Task 71: Add stack inspection (peek) command to REPL
- Task 81: Expand constants library with additional mathematical constants
- Task a1: Add session logging flag (--log) to gt CLI
- Task 91: Integrate reverse history search (Ctrl+R) using readline
This commit includes:
- New: internal/repl/calculator.go - Calculator interface for RPN decoupling
- New: internal/repl/completer.go - AutoCompleteAdapter for readline
- Modified: internal/repl/repl.go - Uses readline instead of go-prompt
- Modified: internal/rpn/variables.go - Added Save/Load for persistent state
- Modified: internal/rpn/rpn_state.go - Added Stack() method
- Modified: internal/rpn/constants.go - Added more mathematical constants
- Modified: internal/repl/commands.go - Added 'stack' command
- Modified: internal/repl/completer_test.go - Updated for readline API
- Modified: internal/repl/repl_test.go - Updated for Calculator interface
- Modified: internal/repl/concurrent_test.go - Updated for Calculator interface
- Modified: internal/repl/handlers.go - Updated for Calculator interface
- Modified: internal/rpn/variables_test.go - Added Save/Load tests
- Modified: internal/rpn/constants_test.go - Added new constant tests
- Modified: cmd/gt/main.go - Added --log flag support
- Modified: Magefile.go - Symmetrized Install/Uninstall logic
- Deleted: internal/repl/prompt.go - Replaced by readline integration
- Added: STORY.md - Project history documentation
|
|
|
|
Integration tests that use the gt tool directly via exec.Command
have been moved from cmd/gt/cli_test.go to integrationtests/cli_test.go.
Unit tests in cmd/gt/main_test.go remain in place as they test
internal functions (runCommand) rather than the binary.
Package declaration changed from 'main' to 'integrationtests'.
|
|
- Fix error handling in test files by explicitly ignoring error returns
- Remove trailing punctuation from error message in rpn_parse.go
Test file changes:
- cli_test.go: Use _ = os.Remove() in Cleanup function
- concurrent_test.go: Use _, _ = runRPN() in concurrent goroutines
Code change:
- rpn_parse.go: Changed error message to end with 'colon' instead of ':'
|
|
|
|
|
|
|
|
|
|
Renamed internal/calculator directory to internal/perc, updated package name from 'calculator' to 'perc', and updated all import references.
|
|
|
|
Created new files for better separation of concerns:
- internal/rpn/mode.go: CalculationMode enum
- internal/rpn/rpn_state.go: RPN struct and state management
- internal/rpn/rpn_ops.go: Operator execution and evaluation
- internal/rpn/rpn_parse.go: Parsing and assignment handling
Original rpn.go now contains only the RPN struct and constructor.
Benefits:
- Better Single Responsibility Principle (SRP)
- Improved code organization and readability
- Easier to maintain and test individual components
|
|
- Added SPDX header to cmd/gt/cli_test.go
- Added SPDX header to internal/rpn/boolean_test.go
All 27 .go source files now have SPDX license headers with MIT license
and copyright notice for Paul Buetow (c) 2026.
|
|
- Created cmd/gt/cli_test.go with end-to-end CLI tests
- Tests:
- TestCLIVersionOnly: Tests 'gt version' command
- TestCLIPercentageCalculation: Tests percentage calculations
- TestCLIRPNCalculation: Tests RPN calculations
- TestCLIExitCode: Tests proper exit codes
- TestCLIInvalidPercentage: Tests invalid percentage input
- TestCLIInvalidRPN: Tests invalid RPN expressions
All tests pass and build correctly.
|
|
- Added 'SPDX-License-Identifier: MIT' and 'Copyright (c) 2026 Paul Buetow' headers
- Files updated: 24 .go files across cmd/gt/, internal/calculator/, internal/repl/, internal/rpn/
The MIT license from LICENSE file is reflected in all source files.
|
|
- Enhanced Package gt documentation with detailed usage examples for percentage calculations and RPN expressions
- Added architecture overview section
- Enhanced Package internal documentation with version format, build instructions, and usage examples
- All tests pass and application builds correctly
|
|
- Add RPN (Reverse Polish Notation) calculator with stack-based operations
- Support precise rational number calculations using *big.Rat
- Implement chain of responsibility pattern for command handling
- Add auto-completion for built-in commands
- Add history persistence with configurable max entries
- Support standard operators: +, -, *, /, ^, %, lg, log, ln
- Support hyper operators: [+], [-], [*], [/], [^], [%], [lg], [log], [ln]
- Support stack manipulation: dup, swap, pop, show
- Support variable assignments and management
- Add rat mode for switching between float64 and rational calculations
- Refactor calculator to return Calculation struct with formatting
- Add proper version support (v0.3.0)
All changes follow Go best practices with comprehensive test coverage.
|
|
- 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.
|
|
- Error wrapping improvements across multiple files
- Thread-safe singleton initialization using sync.Once
- Proper error handling for file close operations
- Removed speculative complexity in history management
- Fixed operator interface design
Audit report: COMPLETE_AUDIT_REPORT.md
|
|
|
|
- Changed Operations.vars from *Variables to VariableStore interface
- Changed NewOperations to accept VariableStore interface
- Changed RPN.vars from *Variables to VariableStore interface
- Changed NewRPN to accept VariableStore interface
- Removed type assertions in main.go and repl.go
- Added FormatVariables to VariableStore interface
- All tests pass, build successful
|
|
- Bare expressions like '1 2 +' now work without 'calc' prefix
- Assignment format 'name value =' requires 'calc' subcommand prefix
|
|
- 21 test functions covering version, calc, rpn subcommands
- Tests for assignment, percentage calculations, error handling, repl mode
- Coverage: runCommand 91.7%, runRPN 100%, printUsage 100%
|
|
- Test version, calc, rpn subcommands
- Test percentage calculations
- Test error handling (missing expressions, division by zero, unknown tokens)
- Test assignment with variables
- Test printUsage function
- Achieve 76% coverage of cmd/perc package
|
|
- Add calc and rpn subcommands to main.go
- Support RPN expression evaluation via perc calc/rpn <expr>
- Support variable assignment format: 'name value = expr...'
- Fix assignment parsing to handle 'name value = expression' format
- All tests pass, go vet passes
|
|
- Add REPL mode with vi keybindings
- Add built-in commands (help, clear, quit/exit)
- Add mage repl target
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
|
Amp-Thread-ID: https://ampcode.com/threads/T-e4f4a959-8cc6-4ac0-b6fb-2779867e8b2a
Co-authored-by: Amp <amp@ampcode.com>
|