How jonaustin/vpet works
Main Components
• Command-Line Interface (CLI) Module – Represented by main.go. This is where the interactive mode is started as well as non-interactive stat updates.
• Stat and Lifecycle Management Module – This internal module (within main.go) handles lifecycle phases (Baby, Child, Adult), stat management (health, hunger, energy, happiness, age), and the application of decay rates or care effects.
• Persistence Layer – Although implemented simply, the pet’s state is saved to a configuration file (~/.config/vpet/pet.json). Represent this as a separate component responsible for reading/writing pet state data.
• Tmux Integration – Represented by the “vpet.tmux” file and the “scripts/pet_status.sh.” This component is responsible for interfacing with tmux to display the pet’s current status (happy, hungry, tired, etc.).
Relationships and Interactions
• The CLI Component accepts user input (navigating menus, selecting actions such as Feed, Medicine, Play, Discipline, Sleep) which then triggers changes in the pet’s stats.
• The Stat and Lifecycle Management Module calculates these stat changes and the passage of time (simulating aging, health decay, etc.). It also triggers events like sickness or death based on stat thresholds.
• The Persistence Layer is used to save the pet’s state so the pet continues aging even when the program isn’t actively running. This ensures that changes in the pet’s life cycle are permanent.
• The Tmux Integration component pulls the latest pet status (by running the provided script and using the tmux file integration) to visually represent the pet's state in the terminal.
• Testing routines (managed in main_test.go) validate the core logic behind stat management and interaction handling.
Architectural Patterns and Design Principles
• Single Responsibility – Each module (user interaction, pet state management, system integration, persistence) performs a clearly defined role.
Relevant Technologies, Frameworks, or Libraries
• Go (the programming language) – This is the main language used.
• Tmux – For integrating and displaying the pet’s status in the terminal.
• Shell Scripting – As seen in the "scripts/pet_status.sh," which may be used to interface with or supplement the Go application in the tmux environment.