@@ -7,33 +7,40 @@ import {
7
7
8
8
@injectable ( )
9
9
export class MonitorSettingsProviderImpl implements MonitorSettingsProvider {
10
+ // this is populated with all settings coming from the CLI. This should never get modified
11
+ // as it is used to double actual values set by the user
12
+ private monitorSettings : MonitorSettings ;
13
+
14
+ // this contains values for setting of the monitorSettings
15
+ // the key is MonitorSetting.id, the value should be one of the MonitorSetting.values
16
+ private monitorSettingsValues : Record < string , any > ;
17
+
10
18
init (
11
19
id : string ,
12
20
coreClientProvider : CoreClientProvider
13
21
) : Promise < MonitorSettings > {
14
22
throw new Error ( 'Method not implemented.' ) ;
15
23
16
- // query the CLI (via coreClientProvider) and return all available settings for the pluggable monitor.
17
- // store these for later checkings
18
-
19
- // check for the settings file in the user's home directory
20
- // if it doesn't exist, create it
21
-
22
- // if it does exist, start searching for the longest prefix matching the id
24
+ // 1. query the CLI (via coreClientProvider) and return all available settings for the pluggable monitor.
25
+ // store these in `monitorSettings` for later checkings
23
26
24
- // at the end of the search you can have a hit or a miss
25
-
26
- // if you have a miss, create a new entry with the id and all default settings coming from the CLI
27
-
28
- // if you have a hit, check if the existing settings are present in the settings from the CLI
29
- // if they are not present in the CLI, remove from the settings file
30
- // if there are settings in the CLI that are not in the file, add to the file with the default from the CLI
31
- // save the updated settings file
27
+ // 2. check for the settings file in the user's home directory
28
+ // a. if it doesn't exist, create it as an empty json file
29
+ // 3. search the file, looking for the longest prefix matching the id
30
+ // a. miss: populate `monitorSettingsValues` with all default settings from `monitorSettings`
31
+ // b. hit: populate `monitorSettingsValues` with the result for the search
32
+ // i. purge the `monitorSettingsValues` removing keys that are not defined in `monitorSettings`
33
+ // and adding those that are missing
34
+ // ii. save the `monitorSettingsValues` in the file, using the id as the key
32
35
}
33
36
get ( ) : Promise < MonitorSettings > {
34
37
throw new Error ( 'Method not implemented.' ) ;
35
38
}
36
39
set ( settings : MonitorSettings ) : Promise < MonitorSettings > {
37
40
throw new Error ( 'Method not implemented.' ) ;
41
+
42
+ // 1. parse the settings parameter and remove any setting that is not defined in `monitorSettings`
43
+ // 2. update `monitorSettingsValues` accordingly
44
+ // 3. save it to the file
38
45
}
39
46
}
0 commit comments