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
//! Problem-handling policy: what to do when `lint` finds something.
//!
//! Rather than hand-rolling a loop every project, declare your policy once and
//! pass it to [`handle_problems`] or [`Model::parse_and_lint`]:
//!
//! ```no_run
//! # use argenv_resolve::*;
//! # let model: Vec<Record> = vec![];
//! # let resolved = argenv_resolve::parse(&model);
//! let findings = lint(&model, &resolved);
//! handle_problems(&findings, OnProblems::FailOnError);
//! ```
use crate::;
/// What to do when [`crate::lint`] returns findings.
///
/// Pass to [`handle_problems`] or, more commonly, let [`crate::contract!`]'s
/// generated `Model::parse_and_lint` handle both steps at once.
/// Apply a problem-handling policy to a set of findings.
///
/// Prints findings to stderr and exits the process if the policy requires it.
/// Returns normally when the policy allows the program to continue.
///
/// Severities come from the default, strict, [`LintPolicy`]; see
/// [`handle_problems_with`] to use another.
///
/// ```no_run
/// # use argenv_resolve::*;
/// # let model: Vec<Record> = vec![];
/// # let resolved = argenv_resolve::parse(&model);
/// handle_problems(&lint(&model, &resolved), OnProblems::FailOnError);
/// ```
/// [`handle_problems`], with this program's own idea of how serious each finding is.
///
/// ```no_run
/// # use argenv_resolve::*;
/// # let model: Vec<Record> = vec![];
/// # let resolved = argenv_resolve::parse(&model);
/// // A wrapper that forwards flags it does not declare: typos are only worth a warning.
/// let forgiving = LintPolicy::default().unknown_flags(Severity::Warning);
/// handle_problems_with(&lint(&model, &resolved), OnProblems::FailOnError, &forgiving);
/// ```