Skip to content

feat(go-cli): list installed apps commands#112

Merged
nicotsx merged 1 commit into
developfrom
feat/go-installed-command
May 18, 2025
Merged

feat(go-cli): list installed apps commands#112
nicotsx merged 1 commit into
developfrom
feat/go-installed-command

Conversation

@nicotsx
Copy link
Copy Markdown
Collaborator

@nicotsx nicotsx commented May 18, 2025

Summary by CodeRabbit

  • New Features

    • Added a new CLI command to list installed applications, providing users with an easy way to view all installed apps.
  • Improvements

    • Enhanced internal logic for constructing API URLs, resulting in more consistent and reliable API calls.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2025

Walkthrough

A new installed CLI command was introduced to list installed apps by querying an API endpoint. Supporting logic for the command was added, including HTTP request handling and response parsing. The API base URL construction was refactored and centralized into a utility function, which was also newly introduced.

Changes

File(s) Change Summary
go-cli/cmd/runtipi/main.go Added a new top-level installed command that invokes commands.RunInstalled() when executed.
go-cli/internal/commands/installed.go Introduced new logic to fetch and display installed apps via an API call, with spinner UI and error handling.
go-cli/internal/commands/app.go Refactored API base URL construction to use the new utils.GetAPIBaseURL utility function.
go-cli/internal/utils/api.go Added a new GetAPIBaseURL function to generate API URLs based on environment variables and endpoint names.

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
Loading

Possibly related PRs

Suggested labels

size/M

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
go-cli/internal/commands/installed.go (3)

13-79: Consider simplifying spinner finish logic

The 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 parsing

Using a typed struct instead of map[string]any would 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 format

Currently, 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

📥 Commits

Reviewing files that changed from the base of the PR and between c853227 and 4243455.

📒 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 installed command 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 command

The 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 implementation

The GetAPIBaseURL function 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 maintainability

Good 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 good

The RunInstalled function 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.

@nicotsx nicotsx merged commit df02dd4 into develop May 18, 2025
3 checks passed
@nicotsx nicotsx deleted the feat/go-installed-command branch May 18, 2025 07:43
@coderabbitai coderabbitai Bot mentioned this pull request Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant