Separate cli functionality and data structure.#22
Separate cli functionality and data structure.#22shahriaarrr merged 1 commit intoshahriaarrr:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR decouples CLI presentation logic from the core Todos data structure by removing the Print method and moving it into the CLI application, while exposing color helpers for external use.
- Removed
Print()fromtasky.goto isolate data model from output formatting - Updated
colors.goto export color functions (Red,Green,Blue) - Added
PrintTablein the CLI (cli/tasky/main.go) and updated calls accordingly
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tasky.go | Removed the Print method to separate CLI logic from the data model |
| colors.go | Renamed color helpers to exported functions for external visibility |
| cli/tasky/main.go | Introduced PrintTable, updated imports, and replaced tasks.Print |
Comments suppressed due to low confidence (2)
colors.go:16
- [nitpick] Add a Go doc comment above
Redto describe its behavior, following Go documentation conventions for exported functions.
func Red(s string) string {
cli/tasky/main.go:235
- Consider adding a unit test for
PrintTableto validate table formatting and edge cases (e.g., empty list, all tasks done).
func PrintTable(tasks tasky.Todos) {
| completedAt := "-" | ||
|
|
||
| if item.Done { | ||
| task = tasky.Green(item.Task) // green(item.Task) |
There was a problem hiding this comment.
Remove the commented-out // green(item.Task) comment to clean up redundant code.
| task = tasky.Green(item.Task) // green(item.Task) | |
| task = tasky.Green(item.Task) |
|
|
||
| "github.com/alexeyco/simpletable" | ||
|
|
There was a problem hiding this comment.
[nitpick] Group external imports (github.com/alexeyco/simpletable, github/tasky) on a separate block below the stdlib imports for clarity.
| "github.com/alexeyco/simpletable" | |
| ) | |
| import ( | |
| "github.com/alexeyco/simpletable" |
|
Hi dear @dhufe 👋 Unfortunately, I am not able to check this PR right now due to the Israeli invasion of my country, Iran, which has caused me to lose focus on my work and life. Of course, a ceasefire was established between them a day or two ago, but I still haven't been able to mentally organize my mind. That's why I can't check your PR right now, and I really apologize for that, but I will definitely do so in the next few days and merge this PR.🙏❤️ |
|
Hi @shahriaarrr, don't worry, life comes first 😉. Currently I'm working on a tui-app just for fun. If you're interested, leave me a comment. |
Hi again and thanks. you can contact me with my email and share your ideas about it: shahriaarrr@gmail.com |


Hey there, when I was looking on your code I noticed that the Print()-function in tasky.go is only called by the cli-application and should be implemented in the application code and not in the data structure to separate them code. This also required to make the color-Methods public, since they aren't in the same package anymore.
It would be clearer if anyone wants to use the data struct for other applications (like in my case I'm using it to implement a bubbletea tui for it).
Cheers,
Daniel