Skip to content

feat: add workspace list command and short alias#24

Merged
feloy merged 2 commits intokortex-hub:mainfrom
feloy:cmd-workspace
Mar 6, 2026
Merged

feat: add workspace list command and short alias#24
feloy merged 2 commits intokortex-hub:mainfrom
feloy:cmd-workspace

Conversation

@feloy
Copy link
Contributor

@feloy feloy commented Mar 6, 2026

Adds the command kortex-cli workspace list and an alias kortex-cli list

Example:

$ kortex-cli workspace list
ID: a55bd85c6430656be5f656feda9771477f75d4d92c3a051f9fa4bba12e91c181
  Sources: /Users/phmartin/Documents/gits/kortex-cli/cmd-init
  Configuration: /Users/phmartin/Documents/gits/kortex-cli/cmd-init/.kortex

ID: ecf2362d804f00382011f7496583d2a8467b6a9c2ebbdf878091626c82a5d475
  Sources: /Users/phmartin/Documents/gits/kortex-cli/cmd-init
  Configuration: /Users/phmartin/Documents/gits/kortex-cli/cmd-init/.kortex

$ kortex-cli list
ID: a55bd85c6430656be5f656feda9771477f75d4d92c3a051f9fa4bba12e91c181
  Sources: /Users/phmartin/Documents/gits/kortex-cli/cmd-init
  Configuration: /Users/phmartin/Documents/gits/kortex-cli/cmd-init/.kortex

ID: ecf2362d804f00382011f7496583d2a8467b6a9c2ebbdf878091626c82a5d475
  Sources: /Users/phmartin/Documents/gits/kortex-cli/cmd-init
  Configuration: /Users/phmartin/Documents/gits/kortex-cli/cmd-init/.kortex

Signed-off-by: Philippe Martin <phmartin@redhat.com>

Co-Authored-By: Claude Code (Claude Sonnet 4.5) <noreply@anthropic.com>
@feloy feloy requested a review from benoitf March 6, 2026 14:47
@coderabbitai
Copy link

coderabbitai bot commented Mar 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7eea2cf4-9425-4487-b707-5d7b52fb358a

📥 Commits

Reviewing files that changed from the base of the PR and between 92c0b59 and a882ae7.

📒 Files selected for processing (7)
  • pkg/cmd/list.go
  • pkg/cmd/list_test.go
  • pkg/cmd/root.go
  • pkg/cmd/workspace.go
  • pkg/cmd/workspace_list.go
  • pkg/cmd/workspace_list_test.go
  • pkg/cmd/workspace_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • pkg/cmd/root.go
  • pkg/cmd/list.go

📝 Walkthrough

Walkthrough

Adds a workspace command hierarchy and a reusable workspace list command. The list command initializes an instances.Manager from the global --storage flag and prints registered workspaces (or a no-workspaces message). A top-level list alias is added and both commands are registered on the root.

Changes

Cohort / File(s) Summary
Core Workspace Listing
pkg/cmd/workspace_list.go, pkg/cmd/workspace_list_test.go
Adds workspace list command with PreRunE that reads --storage, constructs instances.Manager, and RunE that enumerates and prints workspaces. Tests cover construction, PreRun, and end-to-end scenarios (empty, single, multiple, alias).
Workspace Command Hierarchy
pkg/cmd/workspace.go, pkg/cmd/workspace_test.go
Introduces workspace parent command which registers the workspace list subcommand; test verifies command Use and presence of list subcommand.
List Command Alias
pkg/cmd/list.go, pkg/cmd/list_test.go
Adds top-level list command that wraps/delegates to the workspace list command and copies its flags; test asserts command creation and Use value.
Root Command Integration
pkg/cmd/root.go
Wires NewWorkspaceCmd() and NewListCmd() into the root command alongside existing subcommands.

Sequence Diagram

sequenceDiagram
    actor User
    participant CLI as Root CLI / list
    participant WkspList as workspaceListCmd
    participant Manager as instances.Manager
    participant Storage as Storage (fs)

    User->>CLI: run "list"
    CLI->>WkspList: PreRunE (read --storage, init manager)
    WkspList->>Manager: New Manager(storageDir)
    Manager->>Storage: read workspace configs
    Storage-->>Manager: workspace instances
    CLI->>WkspList: RunE (invoke list)
    WkspList->>Manager: List()
    Manager-->>WkspList: instances[]
    WkspList->>CLI: print workspaces or "No workspaces registered"
    CLI-->>User: display output
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'feat: add workspace list command and short alias' directly and accurately summarizes the main changes: adding a workspace list command and an alias for it.
Description check ✅ Passed The PR description is directly related to the changeset, providing example usage of both 'kortex-cli workspace list' and 'kortex-cli list' commands with sample output showing workspace IDs and metadata.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

Copy link

@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.

🧹 Nitpick comments (2)
pkg/cmd/workspace_list_test.go (1)

230-231: Remove unused import workaround.

The os package is imported but not used in any actual test logic. The var _ = os.Stat is dead code added solely to silence the unused import warning. Consider removing both.

🧹 Proposed cleanup
 import (
 	"bytes"
-	"os"
 	"path/filepath"
 	"strings"
 	"testing"

 	"github.com/kortex-hub/kortex-cli/pkg/instances"
 )

And remove lines 230-231:

-// Ensure we don't import os without using it
-var _ = os.Stat
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/cmd/workspace_list_test.go` around lines 230 - 231, Remove the dead-code
workaround that silences the unused import: delete the `var _ = os.Stat` line
and also remove the unused `os` entry from the import block so the `os` package
is no longer imported; this cleans up the unused-import warning without adding
no-op references.
pkg/cmd/workspace_list.go (1)

86-86: TODO comment: Add flags as needed.

This TODO indicates potential future enhancements for the list command (e.g., output format flags like --json, --quiet, or filtering options).

Would you like me to open an issue to track this enhancement, or help implement specific flags such as --output=json or --quiet?

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/cmd/workspace_list.go` at line 86, The TODO about adding flags to the
workspace list command should be resolved: either remove the TODO and add an
issue to track enhancement, or implement common flags now (e.g., add --output/-o
with values json|plain and a --quiet/-q boolean) on the command constructor
(e.g., NewWorkspaceListCmd or the workspace list command variable), wire the
flags into the command's Run handler to change output formatting and verbosity,
validate flag values, and update help text and tests; if you prefer tracking,
create an issue referencing the TODO and remove or replace the TODO with a short
comment linking the issue.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/cmd/workspace_list_test.go`:
- Around line 230-231: Remove the dead-code workaround that silences the unused
import: delete the `var _ = os.Stat` line and also remove the unused `os` entry
from the import block so the `os` package is no longer imported; this cleans up
the unused-import warning without adding no-op references.

In `@pkg/cmd/workspace_list.go`:
- Line 86: The TODO about adding flags to the workspace list command should be
resolved: either remove the TODO and add an issue to track enhancement, or
implement common flags now (e.g., add --output/-o with values json|plain and a
--quiet/-q boolean) on the command constructor (e.g., NewWorkspaceListCmd or the
workspace list command variable), wire the flags into the command's Run handler
to change output formatting and verbosity, validate flag values, and update help
text and tests; if you prefer tracking, create an issue referencing the TODO and
remove or replace the TODO with a short comment linking the issue.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 62357c96-94f8-4ce3-a6eb-ad9adb9eb17b

📥 Commits

Reviewing files that changed from the base of the PR and between b20b222 and 92c0b59.

📒 Files selected for processing (7)
  • pkg/cmd/list.go
  • pkg/cmd/list_test.go
  • pkg/cmd/root.go
  • pkg/cmd/workspace.go
  • pkg/cmd/workspace_list.go
  • pkg/cmd/workspace_list_test.go
  • pkg/cmd/workspace_test.go

Signed-off-by: Philippe Martin <phmartin@redhat.com>

Co-Authored-By: Claude Code (Claude Sonnet 4.5) <noreply@anthropic.com>
Copy link
Contributor

@benoitf benoitf left a comment

Choose a reason for hiding this comment

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

I was expecting a tabular view but the command works

tab rendering can come later

and probably needs first the JSON output

@feloy feloy merged commit da03481 into kortex-hub:main Mar 6, 2026
6 checks passed
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.

2 participants