Skip to content

Make the codebase in my way#9

Merged
5ouma merged 2 commits intomainfrom
refactor-clean-up-codebase
Dec 31, 2025
Merged

Make the codebase in my way#9
5ouma merged 2 commits intomainfrom
refactor-clean-up-codebase

Conversation

@5ouma
Copy link
Owner

@5ouma 5ouma commented Dec 31, 2025

Clean up the Cobra command options, logging, and tests.

Clean up the cobra command options and logging.

Signed-off-by: Souma <git@5ouma.me>
Check they work successfully as expected.

Signed-off-by: Souma <git@5ouma.me>
@5ouma 5ouma self-assigned this Dec 31, 2025
@5ouma 5ouma added 🔧 Maintenance Repository Maintenance 🧪 Testing Adding missing tests or correcting existing tests labels Dec 31, 2025
@5ouma 5ouma merged commit 94789f3 into main Dec 31, 2025
3 of 4 checks passed
@5ouma 5ouma deleted the refactor-clean-up-codebase branch December 31, 2025 08:55
@coderabbitai
Copy link

coderabbitai bot commented Dec 31, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request restructures a CLI application from lporg to dorg, consolidating command architecture with a new root command factory. Multiple subcommands are removed (default, revert, version), while load/save are refactored with simplified execution flows. Database integration is replaced with YAML-based configuration, and dependencies are updated to newer versions with ecosystem changes.

Changes

Cohort / File(s) Summary
CLI Command Structure
cmd/command.go, cmd/load.go, cmd/save.go
New command factory New() introduced returning root cobra command. Load and save commands rewritten with constructor functions newLoadCmd() and newSaveCmd(), simplified error handling, direct config verification, and persistent flags --file (default dorg.yml) and --verbose/-V.
Removed Commands
cmd/default.go, cmd/revert.go, cmd/root.go, cmd/version.go
Four files deleted: default command with interactive prompts and backup flow, revert command with config loading, root command with persistent flags and logging setup, and version command. Functionality consolidated into new command.go.
CLI Tests
cmd/cmd_test.go
New test file added validating command initialization, subcommand presence, version matching, flag exposure (file, verbose), and error behavior when executing with missing resources.
Internal Command Logic
internal/command/command.go, internal/command/command_test.go
Major refactor: Config struct simplified (Cloud, Backup fields removed), Verify logic streamlined, SaveConfig rewritten to use new config.Config and YAML serialization with home-relative path conversion, LoadConfig migrated to config.Load. DefaultOrg removed in favor of utils.RestartDock. Test added for Verify() directory creation.
Configuration System
internal/config/config.go, internal/config/config_test.go
New package introduced for YAML-based dock configuration. Defines Config, Dock, Folder, and DockSettings types with Load() function reading and unmarshaling YAML files. Tests validate successful loading, invalid YAML, and missing files.
Removed Database Code
internal/database/config.go, internal/database/database.go, internal/database/model.go
Three files deleted removing GORM-based LaunchPad database layer: config.go (LoadConfig), database.go (ClearGroups, EnableTriggers, DisableTriggers, TriggersDisabled), and model.go (LaunchPad, Category, Group, Item, DBInfo structs and ORM mappings).
Dock Plist Integration
internal/dock/dock.go, internal/dock/dock_test.go
Major refactor: LoadDockPlist signature simplified (no parameters), AddApp no longer returns error, AddOther accepts config.Folder instead of database.Folder with tilde expansion, ApplySettings accepts config.DockSettings. Plist struct fields reorganized. Save logic uses temporary files. Logging migrated to slog. Tests expanded with new helper validations (FileNameWithoutExt, TilePathGetters, AddApp behavior, AddOther path handling, ApplySettings validation).
Utilities
internal/utils/utils.go, internal/utils/utils_test.go
Logging refactored from apex/log to slog with lipgloss-based UI styling (H1, H2, Msg). New functions: SetLogLevel() mapping verbose to slog levels, RestartDock() killing dock process, Version() reading build info. Tests added for SetLogLevel, RunCommand scenarios, and Version output.
Project Configuration
go.mod, main.go
Module path changed from blacktop/lporg to 5ouma/dorg. Go toolchain updated to 1.25.5. Dependencies reworked: survey, apex/log, sqlite removed; charmbracelet packages added. Indirect dependencies shifted to newer charmbracelet/x and term utilities. main.go updated to use new cmd.New() factory pattern with explicit error handling and exit code.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor-clean-up-codebase

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c0d695b and 18c1253.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (22)
  • cmd/cmd_test.go
  • cmd/command.go
  • cmd/default.go
  • cmd/load.go
  • cmd/revert.go
  • cmd/root.go
  • cmd/save.go
  • cmd/version.go
  • go.mod
  • internal/command/command.go
  • internal/command/command_test.go
  • internal/command/utils.go
  • internal/config/config.go
  • internal/config/config_test.go
  • internal/database/config.go
  • internal/database/database.go
  • internal/database/model.go
  • internal/dock/dock.go
  • internal/dock/dock_test.go
  • internal/utils/utils.go
  • internal/utils/utils_test.go
  • main.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

This was referenced Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔧 Maintenance Repository Maintenance 🧪 Testing Adding missing tests or correcting existing tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant