1
1
//! Coffee configuration utils.
2
- use log:: info;
3
- use serde:: { Deserialize , Serialize } ;
4
2
use std:: env;
5
3
6
- use crate :: CoffeeOperation ;
7
- use coffee_lib:: utils:: { check_dir_or_make_if_missing, copy_dir_if_exist} ;
4
+ use serde:: { Deserialize , Serialize } ;
5
+
6
+ use coffee_lib:: utils:: check_dir_or_make_if_missing;
8
7
use coffee_lib:: { errors:: CoffeeError , plugin:: Plugin } ;
9
8
10
9
use crate :: CoffeeArgs ;
10
+ use crate :: CoffeeOperation ;
11
+
11
12
/// Custom coffee configuration, given by a command line list of arguments
12
13
/// or a coffee configuration file.
13
14
#[ derive( Clone , Debug , Serialize , Deserialize ) ]
14
15
pub struct CoffeeConf {
15
16
/// Network configuration related
16
17
/// to core lightning network
17
18
pub network : String ,
19
+ /// root path plugin manager
20
+ pub root_path : String ,
18
21
/// path of core lightning configuration file
19
22
/// managed by coffee
20
23
pub config_path : String ,
21
24
/// path of the core lightning configuration file
22
25
/// not managed by core lightning
23
- /// (this file included the file managed by coffee)
26
+ ///
27
+ /// This file included the file managed by coffee
24
28
pub cln_config_path : Option < String > ,
25
29
/// root cln directory path
26
30
pub cln_root : Option < String > ,
27
- /// root path plugin manager
28
- pub root_path : String ,
29
31
/// all plugins that are installed
30
32
/// with the plugin manager.
31
33
pub plugins : Vec < Plugin > ,
32
34
/// A flag that indicates if the
33
35
/// user wants to skip the verification
34
36
/// of nurse.
37
+ #[ serde( skip) ]
35
38
pub skip_verify : bool ,
36
39
}
37
40
@@ -47,7 +50,7 @@ impl CoffeeConf {
47
50
def_path = def_path. strip_suffix ( '/' ) . unwrap_or ( & def_path) . to_string ( ) ;
48
51
def_path += "/.coffee" ;
49
52
check_dir_or_make_if_missing ( def_path. to_string ( ) ) . await ?;
50
- info ! ( "creating coffee home at {def_path}" ) ;
53
+ log :: info!( "creating coffee home at {def_path}" ) ;
51
54
52
55
let mut coffee = CoffeeConf {
53
56
network : "bitcoin" . to_owned ( ) ,
@@ -62,14 +65,8 @@ impl CoffeeConf {
62
65
// check the command line arguments and bind them
63
66
// inside the coffee conf
64
67
coffee. bind_cmd_line_params ( conf) ?;
65
-
66
68
check_dir_or_make_if_missing ( format ! ( "{def_path}/{}" , coffee. network) ) . await ?;
67
69
check_dir_or_make_if_missing ( format ! ( "{def_path}/{}/plugins" , coffee. network) ) . await ?;
68
- let repo_dir = format ! ( "{def_path}/{}/repositories" , coffee. network) ;
69
- // older version of coffee has a repository inside the directory
70
- copy_dir_if_exist ( & format ! ( "{def_path}/repositories" ) , & repo_dir) . await ?;
71
- // FIXME: nurse should clean up the `{def_path}/repositories`.
72
- check_dir_or_make_if_missing ( repo_dir) . await ?;
73
70
// after we know all the information regarding
74
71
// the configuration we try to see if there is
75
72
// something stored already to the disk.
@@ -105,10 +102,12 @@ impl CoffeeConf {
105
102
}
106
103
}
107
104
}
108
-
109
- // FIXME: be able to put the directory also in another place!
110
- // for now it is fixed in the Home/.coffee but another good place
111
- // will be, the .lightning dir
112
105
Ok ( ( ) )
113
106
}
107
+
108
+ /// Return the root path of the coffee manager instance
109
+ /// this include also the network path.
110
+ pub fn path ( & self ) -> String {
111
+ format ! ( "{}/{}" , self . root_path, self . network)
112
+ }
114
113
}
0 commit comments