summaryrefslogtreecommitdiffstats
path: root/src/config/util.rs
blob: 4c1deffbc06a647e3ab80fce1f89b5d475138520 (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
//
// Copyright (c) 2020-2021 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.

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

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

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 ~}}
    "#
    ))
}

pub fn default_strict_script_interpolation() -> bool {
    true
}

pub fn default_script_shebang() -> String {
    String::from("#!/bin/bash")
}

pub fn default_build_error_lines() -> usize {
    10
}