git_atomic/config/
source.rs1use std::fmt;
2
3#[derive(Debug, Clone, PartialEq, Eq)]
5pub enum ConfigSource {
6 Default,
8 GitConfig,
10 File,
12 Env,
14 Cli,
16}
17
18impl ConfigSource {
19 pub fn label(&self) -> &str {
21 match self {
22 ConfigSource::Default => "default",
23 ConfigSource::GitConfig => "git config",
24 ConfigSource::File => ".atomic.toml",
25 ConfigSource::Env => "env",
26 ConfigSource::Cli => "cli",
27 }
28 }
29}
30
31impl fmt::Display for ConfigSource {
32 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
33 f.write_str(self.label())
34 }
35}
36
37#[derive(Debug, Clone)]
39pub struct Sourced<T> {
40 pub value: T,
41 pub source: ConfigSource,
42}
43
44impl<T> Sourced<T> {
45 pub fn new(value: T, source: ConfigSource) -> Self {
46 Self { value, source }
47 }
48}