FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cecli/cecli/commands/remove_queue.py at main · cecli-dev/cecli · GitHub
cecli-dev
cecli
Repository navigation
Code
Issues
13
(13)
Pull requests
8
(8)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cecli
/
cecli
/
commands
/
remove_queue.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
119 lines (102 loc) · 4.63 KB
Breadcrumbs
cecli
/
cecli
/
commands
/
remove_queue.py
Copy path
File metadata and controls
119 lines (102 loc) · 4.63 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
"""Remove-queue command for CLI-33: removes prompts from the processing queue."""
from
typing
import
List
from
cecli
.
commands
.
utils
.
base_command
import
BaseCommand
from
cecli
.
commands
.
utils
.
helpers
import
format_command_result
from
cecli
.
helpers
import
command_queue
class
RemoveQueueCommand
(
BaseCommand
):
NORM_NAME
=
"remove-queue"
DESCRIPTION
=
"Remove a prompt from the queue by index, or '*' to clear all"
@
classmethod
async
def
execute
(
cls
,
io
,
coder
,
args
,
**
kwargs
):
"""Execute the remove-queue command with given parameters.
Args:
io: InputOutput instance
coder: Coder instance (may be None for some commands)
args: Command arguments (index number, '*', or empty for interactive)
**kwargs: Additional context
Returns:
Formatted result string
"""
# Sad path: coder.commands is None
if
not
coder
.
commands
:
return
format_command_result
(
io
,
cls
.
NORM_NAME
,
""
,
error
=
"Command system not available. Cannot remove from queue."
,
)
# Sad path: empty queue
if
command_queue
.
get_queue_length
(
coder
)
==
0
:
return
format_command_result
(
io
,
cls
.
NORM_NAME
,
""
,
error
=
"Queue is empty. Nothing to remove."
)
# Handle wildcard: clear entire queue
if
args
and
args
.
strip
()
==
"*"
:
items
=
command_queue
.
clear_queue
(
coder
)
count
=
len
(
items
)
io
.
tool_output
(
f"Removed all
{
count
}
queued prompt(s)."
)
return
f"Successfully executed
{
cls
.
NORM_NAME
}
."
# Handle specific index
if
args
and
args
.
strip
():
try
:
index
=
int
(
args
.
strip
())
-
1
# Convert to 0-based
except
ValueError
:
return
format_command_result
(
io
,
cls
.
NORM_NAME
,
""
,
error
=
f"Invalid index: '
{
args
.
strip
()
}
'. Please provide a number or '*'."
,
)
item
=
command_queue
.
remove_from_queue
(
coder
,
index
)
if
item
is
None
:
queue_len
=
command_queue
.
get_queue_length
(
coder
)
return
format_command_result
(
io
,
cls
.
NORM_NAME
,
""
,
error
=
f"Index
{
args
.
strip
()
}
is out of range. Queue has
{
queue_len
}
item(s)."
,
)
io
.
tool_output
(
f"Removed:
{
item
[
'text'
][:
80
]
}
"
)
return
f"Successfully executed
{
cls
.
NORM_NAME
}
."
# Interactive mode: no args provided
queue
=
command_queue
.
list_queue
(
coder
)
io
.
tool_output
(
"Queued prompts:"
)
for
i
,
item
in
enumerate
(
queue
,
1
):
text
=
item
[
"text"
][:
80
]
if
len
(
item
[
"text"
])
>
80
:
text
+=
"..."
io
.
tool_output
(
f" [
{
i
}
]
{
text
}
"
)
io
.
tool_output
(
"
\n
Enter index to remove, '*' to clear all, or press Enter to cancel:"
)
# In non-interactive mode, just show usage
return
format_command_result
(
io
,
cls
.
NORM_NAME
,
"Usage: /remove-queue <index> | /remove-queue *"
)
@
classmethod
def
get_completions
(
cls
,
io
,
coder
,
args
)
->
List
[
str
]:
"""Get completion options for remove-queue command."""
if
not
coder
.
commands
:
return
[]
queue_len
=
command_queue
.
get_queue_length
(
coder
)
completions
=
[
str
(
i
)
for
i
in
range
(
1
,
queue_len
+
1
)]
completions
.
append
(
"*"
)
return
completions
@
classmethod
def
get_help
(
cls
)
->
str
:
"""Get help text for the remove-queue command."""
help_text
=
super
().
get_help
()
help_text
+=
"
\n
Usage:
\n
"
help_text
+=
" /remove-queue <index> # Remove prompt at given index
\n
"
help_text
+=
" /remove-queue * # Clear the entire queue
\n
"
help_text
+=
" /remove-queue # Interactive mode (shows list, prompts for index)
\n
"
help_text
+=
"
\n
Description:
\n
"
help_text
+=
" Removes a prompt from the in-memory queue by its index number.
\n
"
help_text
+=
" Use '*' to clear all queued prompts at once.
\n
"
help_text
+=
(
" Without arguments, displays the queue and prompts for interactive selection.
\n
"
)
help_text
+=
"
\n
Examples:
\n
"
help_text
+=
" /remove-queue 1 # Remove the first queued prompt
\n
"
help_text
+=
" /remove-queue * # Clear the entire queue
\n
"
help_text
+=
" /remove-queue # Interactive mode
\n
"
help_text
+=
"
\n
See also: /queue, /insert-queue, /list-queue, /run-queue
\n
"
return
help_text
Back
|
FazBrowse Home
|
New Git URL