summaryrefslogtreecommitdiff
path: root/internal/repl
AgeCommit message (Collapse)Author
2026-03-26fix modulePaul Buetow
2026-03-26fix: remove unused variable assignments in test filesPaul Buetow
- internal/repl/repl_test.go: Remove unused state variable assignments - internal/rpn/rpn_test.go: Remove unused result/err variable assignments These changes address golangci-lint 'ineffectual assignment' warnings.
2026-03-26fix: address code quality issues from golangci-lintPaul Buetow
- 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 ':'
2026-03-26feat: Add integration tests for variable assignments and fix RPN parser bugsPaul Buetow
2026-03-25rpn: Add unit test for exact user scenario with x =: incremental assignmentPaul Buetow
2026-03-25rpn: Fix incremental assignment with x =: (take value from stack)Paul Buetow
2026-03-25rpn: Add test for incremental assignment with =: operatorPaul Buetow
2026-03-25rpn: Fix := and =: operators semanticsPaul Buetow
2026-03-25rpn: Fix =: operator pop order for REPL modePaul Buetow
2026-03-25code-quality: Various improvements to code quality and thread safetyPaul Buetow
2026-03-25Rename calculator package to percPaul Buetow
Renamed internal/calculator directory to internal/perc, updated package name from 'calculator' to 'perc', and updated all import references.
2026-03-25docs: Add SPDX license headers to all .go source filesPaul Buetow
- 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.
2026-03-25refactor: Consolidate REPL command descriptions to single sourcePaul Buetow
- Removed duplicate getCommandDescription function from completer.go - Added package-level getCommandDescription in repl.go as single source of truth - Updated defaultGetCommandDescription to delegate to getCommandDescription - Created minimal completer.go that uses getCommandDescription for test compatibility Command descriptions are now defined only once, eliminating duplication between the original completer.go and defaultGetCommandDescription in repl.go. The refactoring maintains: - Backward compatibility (tests still work) - Consistent descriptions across the codebase - Single source of truth for command descriptions
2026-03-25docs: Add comprehensive Go documentation for REPL functionsPaul Buetow
- Enhanced NewREPL documentation with detailed parameter descriptions - Enhanced RunREPL documentation clarifying it's a convenience wrapper - Improved executor documentation explaining backward compatibility and testing usage - Enhanced defaultExecutor documentation with input processing details and panic recovery - Enhanced defaultCompleter documentation with tab-completion behavior details - Enhanced defaultGetCommandDescription documentation with command description details - Improved TTYChecker methods (IsTTY, EnsureTTY) documentation - Improved SignalHandler.Start method documentation All exported and non-exported functions in the REPL package now have comprehensive documentation comments that describe their purpose, parameters, and return values.
2026-03-24test: Improve defaultExecutor and defaultCompleter test coveragePaul Buetow
- Add TestDefaultExecutorCodePaths to test all code paths in defaultExecutor - Improve TestDefaultCompleter to test with multiple input prefixes - Add comprehensive test for unknown commands, built-in commands, and edge cases
2026-03-24refactor: Move RPNState and related declarations to top of repl.goPaul Buetow
- Move RPNState type definition before any functions - Move rpnState and rpnStateOnce variable declarations before any functions - Keep REPL struct and NewREPL constructor at the top (as per Go best practices) - Update getRPNState comment to be more descriptive This change follows Go best practices where constants, global variables, and type definitions should be at the top of the file before functions.
2026-03-24feat: Add RPN mode, rational number support, and improve REPLPaul Buetow
- 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.
2026-03-23Add panic recovery to REPL executor for better resiliencePaul Buetow
Added defer-recover mechanism to the executor function to catch unexpected panics. When a panic occurs, a user-friendly error message is displayed and the REPL can continue to function. This improves the robustness of the REPL when handling unexpected errors.
2026-03-23Code quality audit fixes from comprehensive auditPaul Buetow
- 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
2026-03-23Fix errcheck issues in cmd/perc, internal/repl, and internal/rpn packagesPaul Buetow
2026-03-23.golangci.ymlPaul Buetow
2026-03-23Replace global variable with function in internal/repl/commands.goPaul Buetow
2026-03-23Replace global variable with function in internal/replPaul Buetow
2026-03-23Fix global variable in repl.go with mutex protectionPaul Buetow
2026-03-23Improve test coverage to 81.9% and fix RPN integrationPaul Buetow
- Add comprehensive unit tests for REPL package - Add completer logic tests to cover edge cases - Integrate RPN as fallback in calculator.Parse() - Add ParseRPN function to calculator package - Add tests for RPN fallthrough path The changes bring overall test coverage from ~70% to 81.9%.
2026-03-20internal/calculator/internal/repl: Add missing comments for exported functionsPaul Buetow
- Added Parse() comment in calculator.go - Updated Commands() comment in repl/commands.go to be more descriptive
2026-03-20internal/repl: Reorder functions per Go best practicesPaul Buetow
- Moved public RunREPL function before private functions - Constructor-like getRPNState immediately follows type definition - This aligns with project Go best practices for file organization
2026-03-20internal/repl: Fix incorrect Vi mode documentation in help textPaul Buetow
The help text incorrectly claimed to document Vi mode keybindings. The go-prompt library only supports Common and Emacs key binding modes, not Vi mode. Updated the help text to accurately describe the actual key bindings supported (Emacs mode with Ctrl+A, Ctrl+E, etc.).
2026-03-20feat: Implement persistent RPN state for all RPN-related inputPaul Buetow
- Modified ParseAndEvaluate() to not reset stack at beginning, only initialize if nil - Changed runRPN() to use getRPNState() for persistent state across calls - Fixed Stack type definition ordering in variables.go to follow Go best practices - Updated tests to create fresh RPN instances where independence is needed This enables REPL-style incremental RPN calculations like '3 4 +' followed by '5 +'.
2026-03-20refactor: update Operations to use VariableStore interfacePaul Buetow
- 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
2026-03-20internal/rpn/rpn.go: fix stack state persistence for ParseAndEvaluatePaul Buetow
- Reset currentStack at start of each ParseAndEvaluate call - This ensures test isolation while allowing incremental operations - Added tests for EvalOperator for incremental RPN evaluation - All tests pass, coverage 79.2% for rpn package
2026-03-20README.md: add REPL mode notes about independent command evaluationPaul Buetow
2026-03-20cmd/perc/main.go: try RPN parsing before percentage calculation in command modePaul Buetow
- Bare expressions like '1 2 +' now work without 'calc' prefix - Assignment format 'name value =' requires 'calc' subcommand prefix
2026-03-20cmd/perc: add unit tests with 86% coveragePaul Buetow
- 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%
2026-03-20internal/repl: add RPN support to REPLPaul Buetow
- Import rpn package in repl.go - Add 'rpn' and 'calc' as built-in commands - Update executor to handle 'rpn <expr>' and 'calc <expr>' commands - Add rpn/calc descriptions to help text - All tests pass, go vet passes
2026-03-16bump version to v0.2.0v0.2.0Paul Buetow
- 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>