feat(go-cli): list installed apps commands#112
Conversation
WalkthroughA new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant Spinner
participant API
User->>CLI: Run 'runtipi installed'
CLI->>Spinner: Start spinner ("Fetching installed apps...")
CLI->>API: GET /api/app-lifecycle/installed
API-->>CLI: Response (JSON list of installed apps)
CLI->>Spinner: Stop spinner (success or failure)
CLI->>User: Display list of installed apps or error message
Possibly related PRs
Suggested labels
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
go-cli/internal/commands/installed.go (3)
13-79: Consider simplifying spinner finish logicThe function properly handles various error conditions, but the spinner finish logic is duplicated. There's a redundant call to
spin.Finish()on line 78 since it's already called in several error paths (lines 18, 29, 37, 44, 70).Consider removing the final
spin.Finish()call on line 78 and ensuring it's called appropriately in each return path:- spin.Finish()
32-38: Consider using a typed struct for response parsingUsing a typed struct instead of
map[string]anywould provide better type safety and improve code readability.Consider defining a response struct:
- var response map[string]any - if jsonErr := json.Unmarshal(body, &response); jsonErr != nil { + type InstalledAppsResponse struct { + Installed []struct { + Info struct { + URN string `json:"urn"` + } `json:"info"` + } `json:"installed"` + } + var response InstalledAppsResponse + if jsonErr := json.Unmarshal(body, &response); jsonErr != nil {Then adjust the subsequent code to use this typed structure instead of type assertions.
47-70: Consider enhancing the output formatCurrently, only the URN of each installed app is displayed. Consider providing more information about each app or formatting the output in a more user-friendly way, such as including the app name, version, or status.
#!/bin/bash # Check what other app information is available in the API response rg -A 5 "apps/installed" --type go
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
go-cli/cmd/runtipi/main.go(2 hunks)go-cli/internal/commands/app.go(1 hunks)go-cli/internal/commands/installed.go(1 hunks)go-cli/internal/utils/api.go(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
go-cli/cmd/runtipi/main.go (1)
go-cli/internal/commands/installed.go (1)
RunInstalled(81-87)
go-cli/internal/commands/app.go (1)
go-cli/internal/utils/api.go (1)
GetAPIBaseURL(41-55)
go-cli/internal/utils/api.go (2)
go-cli/internal/utils/env.go (1)
GetEnvMap(17-25)go-cli/internal/utils/constants.go (1)
DefaultNginxPort(4-4)
🔇 Additional comments (5)
go-cli/cmd/runtipi/main.go (2)
117-124: New command implementation looks good!The implementation of the new
installedcommand follows the same pattern as the other commands in the file. The command structure is clear with appropriate usage and description.
213-213: Command properly added to root commandThe new command is correctly registered to the root command, maintaining consistency with the existing commands.
go-cli/internal/utils/api.go (1)
41-55: Good utility function implementationThe
GetAPIBaseURLfunction effectively centralizes the API URL construction logic that was previously duplicated. It handles environment variables correctly with appropriate defaults and follows the DRY principle.One minor suggestion would be to consider adding error logging if environment variables are unexpectedly missing, though the current approach with default values is reasonable.
go-cli/internal/commands/app.go (1)
35-35: Refactoring improves maintainabilityGood refactoring to use the new utility function instead of manually constructing the URL. This change reduces code duplication and makes the codebase more maintainable.
go-cli/internal/commands/installed.go (1)
81-87: Implementation of RunInstalled looks goodThe
RunInstalledfunction is simple and follows the pattern established in other commands. It properly uses the new utility function to construct the API URL and displays appropriate feedback to the user.
Summary by CodeRabbit
New Features
Improvements