mirror of
https://github.com/starship/starship.git
synced 2026-06-23 02:05:51 +07:00
build: bump toml_edit from 0.6.0 to 0.8.0 (#3225)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
+11
-2
@@ -32,9 +32,17 @@ pub fn update_configuration(name: &str, value: &str) {
|
||||
}
|
||||
|
||||
fn handle_update_configuration(doc: &mut Document, name: &str, value: &str) -> Result<(), String> {
|
||||
let mut current_item = &mut doc.root;
|
||||
let mut keys = name.split('.');
|
||||
|
||||
for key in name.split('.') {
|
||||
let first_key = keys.next().unwrap_or_default();
|
||||
if first_key.is_empty() {
|
||||
return Err("Empty table keys are not supported".to_owned());
|
||||
}
|
||||
|
||||
let table = doc.as_table_mut();
|
||||
let mut current_item = table.entry(first_key).or_insert_with(toml_edit::table);
|
||||
|
||||
for key in keys {
|
||||
if !current_item.is_table_like() {
|
||||
return Err("This command can only index into TOML tables".to_owned());
|
||||
}
|
||||
@@ -429,6 +437,7 @@ mod tests {
|
||||
assert!(handle_update_configuration(&mut doc, ".....", "true").is_err());
|
||||
assert!(handle_update_configuration(&mut doc, "a.a.a..a.a", "true").is_err());
|
||||
assert!(handle_update_configuration(&mut doc, "a.a.a.a.a.", "true").is_err());
|
||||
assert!(handle_update_configuration(&mut doc, ".a.a.a.a.a", "true").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user