| Age | Commit message (Collapse) | Author |
|
MetricReader (task ok)
|
|
Handlers accessed repl.rpnState.rpnCalc — three levels of concrete types
violating DIP and Law of Demeter. Define an RPNCalculator interface
capturing only the methods handlers actually need, and expose it via
REPL.RpnCalculator() so handlers depend on the interface, not the
concrete chain of *rpn.RPN.
|
|
- NewRPNState: correct 'config directory' to 'state directory' (XDG state, not config)
- REPL struct: change 'percentage calculator' to 'calculator' (it's primarily RPN)
- NewREPL: clarify that completer parameter is unused and logWriter is only stored
- defaultExecutor: remove claim that 'handled commands are added to history' (code does the opposite)
- defaultCompleter: remove claim about case-insensitivity and descriptions (not implemented)
- RunREPLWithLog: remove claim about logging input/output (logWriter is stored but not used)
|
|
Fix formatting in 12 files to match gofmt standards.
No logical changes.
|
|
Delete internal/repl/calculator.go which defined the Calculator
interface and RPNCalculator adapter. Every method delegated directly
to *rpn.RPN with zero transformation — unnecessary indirection.
RPNState now holds *rpn.RPN directly instead of the Calculator
interface. Updated NewRPNState, NewREPL, handleRatCommand, and
RPNHandler.Handle() to access *rpn.RPN directly.
Removes 71 net lines, zero behavioral changes.
|
|
Task fe: The infinite for loop in Run() can only exit via return
(fmt.Errorf on readline error). The trailing 'return nil' was dead
code flagged by go vet. Removed.
|
|
- 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
|
|
|
|
|
|
|
|
- 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.
|
|
- 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
|
|
|
|
|
|
|
|
|
|
- Moved public RunREPL function before private functions
- Constructor-like getRPNState immediately follows type definition
- This aligns with project Go best practices for file organization
|
|
- 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
|
|
- 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>
|