diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2022-03-29 11:27:43 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-29 11:27:43 +1100 |
commit | 5a6a1eeb3918985ab003fd8d87faebb76410a242 (patch) | |
tree | 9602da13a8b81d0742eecb71063b4fab9e5eb099 /cli/config_file.rs | |
parent | 89dd5dac6219f9a4c04ada4b5a9c812a88c1c2d4 (diff) |
feat(lsp): support API for config file (#14139)
Closes: #13910
Diffstat (limited to 'cli/config_file.rs')
-rw-r--r-- | cli/config_file.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/cli/config_file.rs b/cli/config_file.rs index 156350064..2c1ec7907 100644 --- a/cli/config_file.rs +++ b/cli/config_file.rs @@ -649,6 +649,25 @@ impl ConfigFile { } } + /// Return any tasks that are defined in the configuration file as a sequence + /// of JSON objects providing the name of the task and the arguments of the + /// task in a detail field. + pub fn to_lsp_tasks(&self) -> Option<Value> { + let value = self.json.tasks.clone()?; + let tasks: BTreeMap<String, String> = serde_json::from_value(value).ok()?; + Some( + tasks + .into_iter() + .map(|(key, value)| { + json!({ + "name": key, + "detail": value, + }) + }) + .collect(), + ) + } + pub fn to_tasks_config( &self, ) -> Result<Option<BTreeMap<String, String>>, AnyError> { |