2022-06-18 21:56:31 -07:00
|
|
|
use super::*;
|
2019-11-10 23:17:47 -08:00
|
|
|
|
2020-10-26 18:16:42 -07:00
|
|
|
#[derive(Debug, Eq, PartialEq, IntoStaticStr, Display, Copy, Clone, EnumString)]
|
|
|
|
#[strum(serialize_all = "kebab_case")]
|
|
|
|
pub(crate) enum Keyword {
|
|
|
|
Alias,
|
2022-02-14 18:37:06 -08:00
|
|
|
AllowDuplicateRecipes,
|
2024-05-14 18:39:42 -07:00
|
|
|
AllowDuplicateVariables,
|
2024-05-14 18:55:32 -07:00
|
|
|
Assert,
|
2023-10-11 22:04:46 -07:00
|
|
|
DotenvFilename,
|
2021-04-24 18:29:58 -07:00
|
|
|
DotenvLoad,
|
2023-10-11 22:04:46 -07:00
|
|
|
DotenvPath,
|
2024-05-30 16:12:07 -07:00
|
|
|
DotenvRequired,
|
2020-10-26 18:16:42 -07:00
|
|
|
Else,
|
|
|
|
Export,
|
2022-10-19 19:00:09 -07:00
|
|
|
Fallback,
|
2021-03-28 22:38:07 -07:00
|
|
|
False,
|
2020-10-26 18:16:42 -07:00
|
|
|
If,
|
2022-10-04 17:32:30 -07:00
|
|
|
IgnoreComments,
|
2023-12-19 20:31:51 -08:00
|
|
|
Import,
|
2023-12-27 20:27:15 -08:00
|
|
|
Mod,
|
2021-04-24 18:29:58 -07:00
|
|
|
PositionalArguments,
|
2024-01-12 12:38:23 -08:00
|
|
|
Quiet,
|
2020-10-26 18:16:42 -07:00
|
|
|
Set,
|
|
|
|
Shell,
|
2023-12-19 20:31:51 -08:00
|
|
|
Tempdir,
|
2021-04-24 18:29:58 -07:00
|
|
|
True,
|
2024-06-05 13:16:47 -07:00
|
|
|
Unexport,
|
2022-01-18 11:02:15 -08:00
|
|
|
WindowsPowershell,
|
2022-05-31 13:01:59 -07:00
|
|
|
WindowsShell,
|
2024-05-18 22:41:38 -07:00
|
|
|
X,
|
2020-10-26 18:16:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Keyword {
|
|
|
|
pub(crate) fn from_lexeme(lexeme: &str) -> Option<Keyword> {
|
|
|
|
lexeme.parse().ok()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn lexeme(self) -> &'static str {
|
|
|
|
self.into()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> PartialEq<&'a str> for Keyword {
|
|
|
|
fn eq(&self, other: &&'a str) -> bool {
|
|
|
|
self.lexeme() == *other
|
|
|
|
}
|
|
|
|
}
|
2024-05-18 22:41:38 -07:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn keyword_case() {
|
|
|
|
assert_eq!(Keyword::X.lexeme(), "x");
|
|
|
|
assert_eq!(Keyword::IgnoreComments.lexeme(), "ignore-comments");
|
|
|
|
}
|
|
|
|
}
|