summaryrefslogtreecommitdiffstats
path: root/src/config/util.rs
blob: 5c76fd30466e5620f2fe365982655efb0e89b70e (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//
// Copyright (c) 2020-2022 science+computing ag and other contributors
//
// This program and the accompanying materials are made
// available under the terms of the Eclipse Public License 2.0
// which is available at https://www.eclipse.org/legal/epl-2.0/
//
// SPDX-License-Identifier: EPL-2.0
//

//! This module contains default functions that are called by serde when deserializing the
//! configuration and having to use default values.

/// The default progress bar format
pub fn default_progress_format() -> String {
    String::from("[{elapsed_precise}] ({percent:>3}%): {bar:40.cyan/blue} | {msg}")
}

/// The default spinner format
pub fn default_spinner_format() -> String {
    String::from("[{elapsed_precise}] {spinner} | {msg}")
}

/// The default format that is used to print one package
pub fn default_package_print_format() -> String {
    String::from(indoc::indoc!(
        r#"
            {{i}} - {{p.name}} : {{p.version}}
            {{~ #if print_any}}

            ==================================

            {{#if print_sources}}
            Sources:
            {{#each p.sources}}
                {{@key}} = {{this.url}} - {{this.hash.hash}} ({{this.hash.type}})
            {{/each}}
            {{/if~}}

            {{#if print_dependencies}}
            Dependencies:
            {{#if print_build_deps ~}}
            {{#each p.dependencies.build}}
                {{this}} (build)
            {{/each}}
            {{/if}}
            {{#if print_runtime_deps ~}}
            {{#each p.dependencies.runtime}}
                {{this}} (runtime)
            {{/each}}
            {{/if}}
            {{/if~}}

            {{#if print_patches}}
            Patches:
            {{#each p.patches}}
                {{this}},
            {{/each~}}
            {{/if~}}

            {{#if print_env}}
            Environment:
            {{#each p.environment}}
                {{@key}}={{this}}
            {{/each~}}
            {{/if~}}

            {{~#if print_flags}}
            Flags:
            {{#each p.flags}}
                {{this}}
            {{/each}}
            {{/if~}}

            {{~#if print_allowed_images}}
            Only supported on:
            {{#each p.allowed_images}}
                {{this}}
            {{/each}}
            {{/if~}}

            {{~#if print_denied_images}}
            Denied on:
            {{#each p.denied_images}}
                {{this}}
            {{/each}}
            {{/if~}}

            {{#if print_phases}}
            Phases:
            {{#each p.phases}}
                {{@key}}
            {{/each}}
            {{/if~}}

            {{~#if print_script}}
            {{script}}
            {{/if~}}
            {{~ /if ~}}
        "#
    ))
}

/// The default value for whether strict script interpolation should be used
pub fn default_strict_script_interpolation() -> bool {
    true
}

/// The default value for the shebang
pub fn default_script_shebang() -> String {
    String::from("#!/bin/bash")
}

/// The default value for the number of log lines that should be printed if a build fails
pub fn default_build_error_lines() -> usize {
    10
}