-
Notifications
You must be signed in to change notification settings - Fork 340
refactor: dynamically generate command list #3206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
0e2791b to
b06d192
Compare
| } | ||
|
|
||
| // If this command has subcommands, add them too | ||
| if subcommand.has_subcommands() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this cover the case /context show --expand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we're also missing these now -
"/hooks add",
"/hooks rm",
"/hooks enable",
"/hooks disable",
"/hooks enable-all",
"/hooks disable-all",
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend adding the existing commands as tests here -
| async fn test_chat_hinter_command_hint() { |
Don't need to commit all of those in, only for local testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this cover the case /context show --expand
Why does it only support the “/context show --expand” option? It should only support slash commands and their subcommands.
Looks like we're also missing these now -
"/hooks add",
"/hooks rm",
"/hooks enable",
"/hooks disable",
"/hooks enable-all",
"/hooks disable-all",These subcommands should not exist at present.
| .iter() | ||
| .filter(|p| p.starts_with(word)) | ||
| .map(|s| (*s).to_owned()) | ||
| .map(|s| s.to_string()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, seeing this clippy error -
error: calling `to_string` on `&&str`
--> crates/chat-cli/src/cli/chat/prompt.rs:127:22
|
127 | .map(|s| s.to_string())
| ^^^^^^^^^^^^^ help: try dereferencing the receiver: `(*s).to_string()`
|
= help: `&str` implements `ToString` through a slower blanket impl, but `str` has a fast specialization of `ToString`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#inefficient_to_string
= note: `-D clippy::inefficient-to-string` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::inefficient_to_string)]`
error: could not compile `chat_cli` (lib) due to 1 previous error
Can you run -
cargo clippy --locked --workspace --color always -- -D warnings
cargo +nightly fmt
Issue #, if available:
#3185
Description of changes:
Replace static
COMMANDSarray with dynamic generation to automatically sync available commands with SlashCommandenum definition. This prevents inconsistencies like #3185 where unimplemented commands (e.g.,
/hooks help) appeared in the command list.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.