1use super::*;
2
3#[derive(Debug, Eq, PartialEq, IntoStaticStr, Display, Copy, Clone, EnumString)]
4#[strum(serialize_all = "kebab_case")]
5pub enum Keyword {
6 Alias,
7 AllowDuplicateRecipes,
8 AllowDuplicateVariables,
9 Assert,
10 DotenvFilename,
11 DotenvLoad,
12 DotenvPath,
13 DotenvRequired,
14 Else,
15 Export,
16 Fallback,
17 False,
18 If,
19 IgnoreComments,
20 Import,
21 Mod,
22 PositionalArguments,
23 Quiet,
24 ScriptInterpreter,
25 Set,
26 Shell,
27 Tempdir,
28 True,
29 Unexport,
30 Unstable,
31 WindowsPowershell,
32 WindowsShell,
33 WorkingDirectory,
34 X,
35}
36
37impl Keyword {
38 pub fn from_lexeme(lexeme: &str) -> Option<Keyword> {
39 lexeme.parse().ok()
40 }
41
42 pub fn lexeme(self) -> &'static str {
43 self.into()
44 }
45}
46
47impl<'a> PartialEq<&'a str> for Keyword {
48 fn eq(&self, other: &&'a str) -> bool {
49 self.lexeme() == *other
50 }
51}
52
53#[cfg(test)]
54mod tests {
55 use super::*;
56
57 #[test]
58 fn keyword_case() {
59 assert_eq!(Keyword::X.lexeme(), "x");
60 assert_eq!(Keyword::IgnoreComments.lexeme(), "ignore-comments");
61 }
62}