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
//! This module contains the structs for the configuration files.

use toml::value::Value;

/// Struct for the author. This is read from the global
/// configuration that resides at $HOME/.pi.toml
#[derive(Debug, Deserialize)]
pub struct Author {
    pub name: String,
    pub email: String,
    pub github_username: Option<String>,
}

/// Struct for the global configuration at $HOME/.pi.toml
#[derive(Debug, Deserialize)]
pub struct Config {
    pub version_control: Option<String>,
    pub author: Option<Author>,
    pub license: Option<String>,
    pub user: Option<UserConfig>,
}

/// Struct for directories, files, templates, and scripts to be created.
#[derive(Debug, Deserialize, Clone)]
pub struct Directory {
    pub files: Option<Vec<String>>,
    pub directories: Option<Vec<String>>,
    pub templates: Option<Vec<String>>,
    pub scripts: Option<Vec<String>>,
}

/// Struct for project-specific configuration options
#[derive(Debug, Deserialize, Clone)]
pub struct ProjectConfig {
    pub version_control: Option<String>,
    pub version: Option<String>,
}

/// Struct for a project
#[derive(Debug, Deserialize, Clone)]
pub struct Project {
    pub license: Option<String>,
    pub with_readme: Option<bool>,
    pub files: Directory,
    pub config: Option<ProjectConfig>,
    pub user: Option<UserConfig>,
}

/// Struct for custom user keys
#[derive(Debug, Deserialize, Clone)]
pub struct UserConfig {
    pub toml: Value,
}