| Age | Commit message (Collapse) | Author |
|
|
|
- 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.
|
|
- 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.
|
|
- 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.
|
|
- 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
|
|
- 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.
|
|
- 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
|
|
- 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.
|
|
- 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.
|
|
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.
|
|
- 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
|
|
|
|
|
|
|
|
|
|
|
|
- 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%.
|
|
- Added Parse() comment in calculator.go
- Updated Commands() comment in repl/commands.go to be more descriptive
|
|
- Moved public RunREPL function before private functions
- Constructor-like getRPNState immediately follows type definition
- This aligns with project Go best practices for file organization
|
|
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.).
|
|
- 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 +'.
|
|
- 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
|
|
- 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
|
|
|
|
- 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%
|
|
- 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
|
|
- 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>
|