Skip to content

refactor: Better Command Organization#28

Merged
DylanDevelops merged 8 commits into
mainfrom
ravel/restructure-project
Dec 22, 2025
Merged

refactor: Better Command Organization#28
DylanDevelops merged 8 commits into
mainfrom
ravel/restructure-project

Conversation

@DylanDevelops
Copy link
Copy Markdown
Owner

Pull Request Checklist

  • I have read and followed the contribution guidelines.
  • My pull request targets the main branch of tmpo.
  • I have tested these changes locally on my machine.

Closes #27

Description

This pull request restructures the CLI command organization, updates documentation to match the new structure, and changes how version information is injected at build time. It also removes the old edit.go and delete.go command files, reflecting a migration to a new command layout using subdirectories for better maintainability and clarity.

Command Structure and Codebase Organization:

  • CLI commands are now organized into subdirectories under cmd/ (e.g., tracking/, entries/, history/, setup/, utilities/) instead of single files per command. Each command is now implemented as a constructor function returning *cobra.Command and registered explicitly in root.go. [1] [2] [3]
  • The files cmd/edit.go and cmd/delete.go have been removed, indicating these commands have been migrated to the new structure. [1] [2]

Documentation Updates:

  • The CLI and internal package structure are updated in CONTRIBUTING.md and CLAUDE.md to reflect the new subdirectory-based organization and the move of project detection logic from internal/project/detector.go to internal/project/detect.go. [1] [2] [3] [4] [5]
  • Documentation now describes the new command registration approach, emphasizing constructor functions and explicit registration. [1] [2]

Build and Version Injection:

  • The GoReleaser configuration (.goreleaser.yml) is updated to inject version, commit, and date information into the new cmd/utilities package instead of the old cmd package, and documentation is updated accordingly. [1] [2] [3] [4]

Internal Logic Changes:

  • Project name detection logic is now referenced as internal/project.DetectConfiguredProject() instead of the previous cmd/start.go:DetectProjectName(), and the file location is updated in the documentation. [1] [2]

These changes modernize the codebase structure, improve maintainability, and ensure documentation and build configuration stay in sync with the code.

Commands have been reorganized into subpackages (entries, history, setup, tracking) for better modularity. Project name detection logic is now centralized in internal/project with a new DetectConfiguredProject function, replacing the previous DetectProjectName usage throughout the codebase.
Converted the edit and manual entry commands to return *cobra.Command from functions instead of using package-level variables. This improves modularity and testability, and aligns with best practices for Cobra command structure.
Refactored the delete command to use a function (DeleteCmd) that returns a *cobra.Command instead of a package-level variable. Removed the init() function and moved flag registration into DeleteCmd. This improves modularity and aligns with best practices for Cobra command structure.
Converted pause, resume, start, status, and stop commands from package-level variables to constructor functions returning *cobra.Command. This improves testability and modularity by avoiding global state and making command registration more explicit.
Replaces global command variables and init() registration with exported constructor functions (e.g., ExportCmd, LogCmd, StatsCmd, InitCmd, VersionCmd) for each command. This improves modularity and testability by allowing commands to be instantiated and registered explicitly.
Replaces the global rootCmd variable with a RootCmd() function that constructs the root command and adds subcommands for tracking, history, entries, and setup. This modularizes command registration and improves maintainability.
Moved version-related code and tests from cmd to cmd/utilities for better organization. Updated .goreleaser.yml and root command to reference the new location.
Revised CLAUDE.md and CONTRIBUTING.md to reflect the new organization of CLI commands into subdirectories and the use of constructor functions for command registration. Updated project structure diagrams and descriptions to match the current codebase layout, including new directories and changes to project detection logic.
@DylanDevelops DylanDevelops merged commit 5afe4ad into main Dec 22, 2025
6 checks passed
@DylanDevelops DylanDevelops deleted the ravel/restructure-project branch December 22, 2025 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Project Growing Unorganized

1 participant