@@ -9,7 +9,7 @@ use color_eyre::{
99use directories:: ProjectDirs ;
1010use lazy_static:: lazy_static;
1111use serde:: { Deserialize , Serialize } ;
12- use strum_macros:: { EnumString , VariantNames } ;
12+ use strum_macros:: { EnumIter , EnumString , VariantNames } ;
1313use toml_edit:: DocumentMut ;
1414
1515const DEFAULT_CONFIG_TOML : & str = include_str ! ( "../.config/config.toml" ) ;
@@ -33,7 +33,7 @@ pub struct SystemDescription {
3333 pub architecture : Vec < String > ,
3434}
3535
36- #[ derive( Clone , Debug , Serialize , Deserialize , Default , strum:: Display , EnumString , VariantNames ) ]
36+ #[ derive( Clone , Debug , Serialize , Deserialize , Default , strum:: Display , EnumString , VariantNames , EnumIter ) ]
3737#[ strum( serialize_all = "lowercase" ) ]
3838#[ allow( clippy:: upper_case_acronyms) ]
3939pub enum ComputePlatform {
@@ -331,6 +331,18 @@ impl Config {
331331 let _cfg: ComanConfig = builder. build ( ) ?. try_deserialize ( ) . wrap_err ( "invalid config" ) ?;
332332 Ok ( ( ) )
333333 }
334+
335+ // Returns tuple of bool saying whether a values is set in (default, global, project local) config
336+ pub fn value_source ( & self , key_path : & str ) -> Result < ( bool , bool , bool ) > {
337+ Ok ( (
338+ self . default_layer . get ( key_path) . is_some ( ) ,
339+ self . global_layer . get ( key_path) . unwrap_or_default ( ) . is_some ( ) ,
340+ self . project_layer
341+ . as_ref ( )
342+ . map ( |l| l. get ( key_path) . unwrap_or_default ( ) . is_some ( ) )
343+ . unwrap_or ( false ) ,
344+ ) )
345+ }
334346}
335347
336348pub fn global_config_layer ( ) -> Result < Layer > {
0 commit comments