-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtypes.rs
More file actions
64 lines (58 loc) · 1.4 KB
/
types.rs
File metadata and controls
64 lines (58 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use clap::ValueEnum;
use convert_case::{Case, Casing};
use serde::{Deserialize, Serialize};
#[derive(ValueEnum, Debug, Clone)]
pub enum FileExtension {
Ts,
Js,
Sql,
Mts,
Cts,
Mjs,
Cjs,
}
#[derive(ValueEnum, Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum DatabaseType {
Postgres,
Mysql,
Sqlite,
}
#[derive(ValueEnum, Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum NamingConvention {
Upper,
Lower,
Title,
Camel,
Pascal,
Snake,
Kebab,
}
impl NamingConvention {
pub fn convert(&self, value: &str) -> String {
match &self {
NamingConvention::Upper => value.to_case(Case::Upper),
NamingConvention::Lower => value.to_case(Case::Lower),
NamingConvention::Title => value.to_case(Case::Title),
NamingConvention::Camel => value.to_case(Case::Camel),
NamingConvention::Pascal => value.to_case(Case::Pascal),
NamingConvention::Snake => value.to_case(Case::Snake),
NamingConvention::Kebab => value.to_case(Case::Kebab),
}
}
}
#[derive(ValueEnum, Debug, Clone, Serialize, Deserialize, Copy)]
#[serde(rename_all = "lowercase")]
pub enum LogLevel {
Debug = 4,
Info = 3,
Warning = 2,
Error = 1,
}
impl LogLevel {
/// Check if the current log level is greater than or equal to the other log level
pub fn gte(&self, other: &Self) -> bool {
*self as u8 >= *other as u8
}
}