1pub struct Preset {
11 pub name: &'static str,
13 pub description: &'static str,
15 pub content: &'static str,
17}
18
19pub static PRESETS: &[Preset] = &[
21 Preset {
22 name: "python",
23 description: "Python: PEP 8 warm-ups, == None, mutable defaults, \
24 docstrings, top-level function/class scopes",
25 content: include_str!("../presets/python.yaml"),
26 },
27 Preset {
28 name: "ini",
29 description: "INI: tabs, trailing whitespace, empty values, \
30 duplicate keys, a [server] section example",
31 content: include_str!("../presets/ini.yaml"),
32 },
33 Preset {
34 name: "markdown",
35 description: "Markdown: tabs, trailing whitespace, bare URLs",
36 content: include_str!("../presets/markdown.yaml"),
37 },
38 Preset {
39 name: "sh",
40 description: "Shell: rm with variables, sudo, [ x == y ], \
41 missing shebang, strict-mode suggestion",
42 content: include_str!("../presets/sh.yaml"),
43 },
44 Preset {
45 name: "dockerfile",
46 description: "Dockerfile: unpinned/latest FROM, sudo in RUN, \
47 ADD vs COPY, apt cleanup, missing HEALTHCHECK",
48 content: include_str!("../presets/dockerfile.yaml"),
49 },
50 Preset {
51 name: "toml",
52 description: "TOML: tabs, trailing whitespace, empty values, \
53 spacing, duplicate keys per section",
54 content: include_str!("../presets/toml.yaml"),
55 },
56 Preset {
57 name: "json",
58 description: "JSON: trailing commas, single-quoted strings, \
59 unquoted keys, comments",
60 content: include_str!("../presets/json.yaml"),
61 },
62 Preset {
63 name: "javascript",
64 description: "JavaScript: == vs ===, var declarations, \
65 leftover console.log",
66 content: include_str!("../presets/javascript.yaml"),
67 },
68];
69
70pub fn lookup(name: &str) -> Option<&'static Preset> {
72 PRESETS.iter().find(|preset| preset.name == name)
73}
74
75pub fn names() -> String {
78 PRESETS
79 .iter()
80 .map(|preset| preset.name)
81 .collect::<Vec<_>>()
82 .join(", ")
83}