feat: add support for /diff command (#1389)
Adds support for a `/diff` command comparable to the one available in the TypeScript CLI. <img width="1103" alt="Screenshot 2025-06-26 at 12 31 33 PM" src="https://github.com/user-attachments/assets/5dc646ca-301f-41ff-92a7-595c68db64b6" /> While here, changed the `SlashCommand` enum so the declared variant order is the order the commands appear in the popup menu. This way, `/toggle-mouse-mode` is listed last, as it is the least likely to be used. Fixes https://github.com/openai/codex/issues/1253.
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use strum::IntoEnumIterator;
|
||||
use strum_macros::AsRefStr; // derive macro
|
||||
use strum_macros::AsRefStr;
|
||||
use strum_macros::EnumIter;
|
||||
use strum_macros::EnumString;
|
||||
use strum_macros::IntoStaticStr;
|
||||
@@ -12,9 +10,12 @@ use strum_macros::IntoStaticStr;
|
||||
)]
|
||||
#[strum(serialize_all = "kebab-case")]
|
||||
pub enum SlashCommand {
|
||||
// DO NOT ALPHA-SORT! Enum order is presentation order in the popup, so
|
||||
// more frequently used commands should be listed first.
|
||||
New,
|
||||
ToggleMouseMode,
|
||||
Diff,
|
||||
Quit,
|
||||
ToggleMouseMode,
|
||||
}
|
||||
|
||||
impl SlashCommand {
|
||||
@@ -26,6 +27,9 @@ impl SlashCommand {
|
||||
"Toggle mouse mode (enable for scrolling, disable for text selection)"
|
||||
}
|
||||
SlashCommand::Quit => "Exit the application.",
|
||||
SlashCommand::Diff => {
|
||||
"Show git diff of the working directory (including untracked files)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +40,7 @@ impl SlashCommand {
|
||||
}
|
||||
}
|
||||
|
||||
/// Return all built-in commands in a HashMap keyed by their command string.
|
||||
pub fn built_in_slash_commands() -> HashMap<&'static str, SlashCommand> {
|
||||
/// Return all built-in commands in a Vec paired with their command string.
|
||||
pub fn built_in_slash_commands() -> Vec<(&'static str, SlashCommand)> {
|
||||
SlashCommand::iter().map(|c| (c.command(), c)).collect()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user