Skip to content

Open source AI coding agent. Designed for large projects and real world tasks.

🤖 Plandex → Parse input arguments for ranges and individual indices and update logic to add contexts within specified range to deleteIds map

Dane Schneider8e8c68f7c64d
diff --git a/app/cli/cmd/rm.go b/app/cli/cmd/rm.go
index 4ca22a93..5dde290c 100644
--- a/app/cli/cmd/rm.go
+++ b/app/cli/cmd/rm.go
@@ -7,6 +7,8 @@ import (
"plandex/auth"
"plandex/lib"
"plandex/term"
+ "strconv"
+ "strings"
"github.com/plandex/plandex/shared"
"github.com/spf13/cobra"
@@ -21,6 +23,28 @@ var contextRmCmd = &cobra.Command{
Run: contextRm,
}
+func parseIndices(args []string) map[int]bool {
+ indices := map[int]bool{}
+ for _, arg := range args {
+ if strings.Contains(arg, "-") {
+ parts := strings.Split(arg, "-")
+ start, err1 := strconv.Atoi(parts[0])
+ end, err2 := strconv.Atoi(parts[1])
+ if err1 == nil && err2 == nil && start <= end {
+ for i := start; i <= end; i++ {
+ indices[i] = true
+ }
+ }
+ } else {
+ index, err := strconv.Atoi(arg)
+ if err == nil {
+ indices[index] = true
+ }
+ }
+ }
+ return indices
+}
+
func contextRm(cmd *cobra.Command, args []string) {
auth.MustResolveAuthWithOrg()
lib.MustResolveProject()
@@ -37,10 +61,15 @@ func contextRm(cmd *cobra.Command, args []string) {
}
deleteIds := map[string]bool{}
+ indices := parseIndices(args)
for i, context := range contexts {
+ if indices[i+1] {
+ deleteIds[context.Id] = true
+ continue
+ }
for _, id := range args {
- if fmt.Sprintf("%d", i+1) == id || context.Name == id || context.FilePath == id || context.Url == id {
+ if context.Name == id || context.FilePath == id || context.Url == id {
deleteIds[context.Id] = true
break
} else if context.FilePath != "" {
@@ -88,3 +117,5 @@ func contextRm(cmd *cobra.Command, args []string) {
func init() {
RootCmd.AddCommand(contextRmCmd)
}
+
+