corty_tui/
slash_command.rs1use crate::widgets::constants::{
7 SLASH_COMMAND_ASK_AI_DESC, SLASH_COMMAND_CLEAR_DESC, SLASH_COMMAND_FULLSCREEN_DESC,
8};
9use strum::IntoEnumIterator;
10use strum_macros::{AsRefStr, EnumIter, EnumString, IntoStaticStr};
11
12#[derive(
14 Debug, Clone, Copy, PartialEq, Eq, Hash, EnumString, EnumIter, AsRefStr, IntoStaticStr,
15)]
16#[strum(serialize_all = "kebab-case")]
17pub enum SlashCommand {
18 Clear,
20 AskAI,
22 Fullscreen,
24}
25
26impl SlashCommand {
27 pub fn description(self) -> &'static str {
29 match self {
30 SlashCommand::Clear => SLASH_COMMAND_CLEAR_DESC,
31 SlashCommand::AskAI => SLASH_COMMAND_ASK_AI_DESC,
32 SlashCommand::Fullscreen => SLASH_COMMAND_FULLSCREEN_DESC,
33 }
34 }
35
36 pub fn command(self) -> &'static str {
38 self.into()
39 }
40
41 pub fn requires_input(self) -> bool {
43 match self {
44 SlashCommand::Clear => false,
45 SlashCommand::AskAI => true,
46 SlashCommand::Fullscreen => false,
47 }
48 }
49}
50
51pub fn built_in_slash_commands() -> Vec<SlashCommand> {
53 SlashCommand::iter().collect()
54}