mirror of
https://github.com/sagiegurari/duckscript
synced 2024-07-20 17:55:45 +00:00
Update release command
This commit is contained in:
parent
fda0966424
commit
dd760cfb50
|
@ -55,13 +55,14 @@ impl Command for CommandImpl {
|
|||
(arguments[0].to_string(), false)
|
||||
};
|
||||
|
||||
if recursive {
|
||||
remove_handle_recursive(state, key);
|
||||
let removed = if recursive {
|
||||
remove_handle_recursive(state, key)
|
||||
} else {
|
||||
remove_handle(state, key);
|
||||
}
|
||||
let old_value = remove_handle(state, key);
|
||||
old_value.is_some()
|
||||
};
|
||||
|
||||
CommandResult::Continue(Some(true.to_string()))
|
||||
CommandResult::Continue(Some(removed.to_string()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,30 +68,40 @@ pub(crate) fn remove_handle(
|
|||
handle_state.remove(&key)
|
||||
}
|
||||
|
||||
pub(crate) fn remove_handle_recursive(state: &mut HashMap<String, StateValue>, key: String) {
|
||||
if let Some(state_value) = remove_handle(state, key.to_string()) {
|
||||
match state_value {
|
||||
pub(crate) fn remove_handle_recursive(
|
||||
state: &mut HashMap<String, StateValue>,
|
||||
key: String,
|
||||
) -> bool {
|
||||
match remove_handle(state, key.to_string()) {
|
||||
Some(state_value) => match state_value {
|
||||
StateValue::List(list) => {
|
||||
for value in list {
|
||||
if let StateValue::String(value) = value {
|
||||
remove_handle_recursive(state, value)
|
||||
remove_handle_recursive(state, value);
|
||||
};
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
StateValue::Set(set) => {
|
||||
for value in set {
|
||||
remove_handle_recursive(state, value)
|
||||
remove_handle_recursive(state, value);
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
StateValue::SubState(map) => {
|
||||
for (_, map_value) in map {
|
||||
if let StateValue::String(value) = map_value {
|
||||
remove_handle_recursive(state, value)
|
||||
remove_handle_recursive(state, value);
|
||||
};
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
_ => true,
|
||||
},
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue