feat: Store and display the last executed command in TerminalCog
This commit is contained in:
parent
8d13bb3963
commit
b598df1f82
@ -44,6 +44,7 @@ class TerminalCog(commands.Cog, name="Terminal"):
|
||||
self.terminal_message: discord.Message | None = None
|
||||
self.active_process: subprocess.Popen | None = None
|
||||
self.terminal_view: TerminalView | None = None
|
||||
self.last_command: str | None = None # Store the last command for display after execution
|
||||
try:
|
||||
self.font = ImageFont.truetype(FONT_PATH, FONT_SIZE)
|
||||
except IOError:
|
||||
@ -281,6 +282,8 @@ class TerminalCog(commands.Cog, name="Terminal"):
|
||||
await self.stop_terminal_session(interaction)
|
||||
return
|
||||
|
||||
self.last_command = command # Store command for display after execution
|
||||
|
||||
# For other commands, use subprocess
|
||||
if self.active_process and self.active_process.poll() is None:
|
||||
self.output_history.append("A command is already running. Please wait or refresh.")
|
||||
@ -356,6 +359,11 @@ class TerminalCog(commands.Cog, name="Terminal"):
|
||||
return_code = self.active_process.returncode
|
||||
# Read any final output
|
||||
final_stdout, final_stderr = self.active_process.communicate()
|
||||
|
||||
if self.last_command: # Add the executed command to history
|
||||
self.output_history.append(f"{self.current_cwd}> {self.last_command}")
|
||||
self.last_command = None
|
||||
|
||||
if final_stdout: self.output_history.extend(final_stdout.strip().splitlines())
|
||||
if final_stderr: self.output_history.extend([f"STDERR: {l}" for l in final_stderr.strip().splitlines()])
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user