fix(crew): improve error message when not in crew workspace
- Show clearer error explaining user needs to specify crew name or cd into crew dir - When --rig is specified, list available crew members in that rig Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -29,7 +29,19 @@ func runCrewAt(cmd *cobra.Command, args []string) error {
|
|||||||
// Try to detect from current directory
|
// Try to detect from current directory
|
||||||
detected, err := detectCrewFromCwd()
|
detected, err := detectCrewFromCwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not detect crew workspace from current directory: %w\n\nUsage: gt crew at <name>", err)
|
// Try to show available crew members if we can detect the rig
|
||||||
|
hint := "\n\nUsage: gt crew at <name>"
|
||||||
|
if crewRig != "" {
|
||||||
|
if mgr, _, mgrErr := getCrewManager(crewRig); mgrErr == nil {
|
||||||
|
if members, listErr := mgr.List(); listErr == nil && len(members) > 0 {
|
||||||
|
hint = fmt.Sprintf("\n\nAvailable crew in %s:", crewRig)
|
||||||
|
for _, m := range members {
|
||||||
|
hint += fmt.Sprintf("\n %s", m.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fmt.Errorf("could not detect crew workspace from current directory: %w%s", err, hint)
|
||||||
}
|
}
|
||||||
name = detected.crewName
|
name = detected.crewName
|
||||||
if crewRig == "" {
|
if crewRig == "" {
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ func detectCrewFromCwd() (*crewDetection, error) {
|
|||||||
// Look for pattern: <rig>/crew/<name>/...
|
// Look for pattern: <rig>/crew/<name>/...
|
||||||
// Minimum: rig, crew, name = 3 parts
|
// Minimum: rig, crew, name = 3 parts
|
||||||
if len(parts) < 3 {
|
if len(parts) < 3 {
|
||||||
return nil, fmt.Errorf("not in a crew workspace (path too short)")
|
return nil, fmt.Errorf("not inside a crew workspace - specify the crew name or cd into a crew directory (e.g., gastown/crew/max)")
|
||||||
}
|
}
|
||||||
|
|
||||||
rigName := parts[0]
|
rigName := parts[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user