Skip to content

Commit d621188

Browse files
cailmdaleyclaude
andcommitted
feat: felt rm --force auto-unlinks dependents before deleting
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 37e948c commit d621188

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

cmd/status.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,30 @@ var rmCmd = &cobra.Command{
2424
return err
2525
}
2626

27+
force, _ := cmd.Flags().GetBool("force")
28+
2729
// Check if anything depends on this
2830
felts, err := storage.List()
2931
if err != nil {
3032
return err
3133
}
3234
for _, other := range felts {
3335
if other.DependsOn.HasID(f.ID) {
34-
return fmt.Errorf("cannot delete: %s depends on this felt", other.ID)
36+
if !force {
37+
return fmt.Errorf("cannot delete: %s depends on this felt", other.ID)
38+
}
39+
// Auto-unlink
40+
var newDeps felt.Dependencies
41+
for _, d := range other.DependsOn {
42+
if d.ID != f.ID {
43+
newDeps = append(newDeps, d)
44+
}
45+
}
46+
other.DependsOn = newDeps
47+
if err := storage.Write(other); err != nil {
48+
return fmt.Errorf("unlinking %s: %w", other.ID, err)
49+
}
50+
fmt.Printf("Unlinked %s → %s\n", other.ID, f.ID)
3551
}
3652
}
3753

@@ -46,4 +62,5 @@ var rmCmd = &cobra.Command{
4662

4763
func init() {
4864
rootCmd.AddCommand(rmCmd)
65+
rmCmd.Flags().BoolP("force", "f", false, "Auto-unlink dependents before deleting")
4966
}

0 commit comments

Comments
 (0)