Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/functions/functions.zone | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/src/functions/functions.zone b/src/functions/functions.zone index 28a22fe..091bcd6 100644 --- a/src/functions/functions.zone +++ b/src/functions/functions.zone @@ -550,28 +550,43 @@ zone_config() { zone_config_new "${zone}" "$@" ;; destroy) + # id could be also a valid hid local id=${1} - if zone_config_id_is_valid ${zone} ${id}; then + # usually we will get a hid so we check first if we get one + if zone_config_hid_is_valid ${zone} ${id}; then + # Convert the hid into an id + id=$(zone_config_convert_hid_to_id ${zone} ${id}) zone_config_destroy "${zone}" "$@" else - log ERROR "${id} is not a valid id" + # We get no valid hid so we check if we get a valid id + if zone_config_id_is_valid ${zone} ${id}; then + zone_config_destroy "${zone}" "$@" + else + log ERROR "${id} is not a valid id or hid" + fi fi ;; list) zone_config_list "${zone}" "$@" ;; *) - # Check is we get a valid id - # TODO This could be also a valid hid + # id could be also a valid hid local id=${cmd} - - if zone_config_id_is_valid ${zone} ${id} && [[ ${1} == "edit" ]]; then + # usually we will get a hid so we check first if we get one + if zone_config_hid_is_valid ${zone} ${id} && [[ ${1} == "edit" ]]; then + id=$(zone_config_convert_hid_to_id ${zone} ${id}) shift 1 zone_config_edit "${zone}" "${id}" "$@" else - error "Unrecognized argument: ${cmd}" - cli_usage root-zone-config-subcommands - exit ${EXIT_ERROR} + # We get no valid hid so we check if we get a valid id + if zone_config_id_is_valid ${zone} ${id} && [[ ${1} == "edit" ]]; then + shift 1 + zone_config_edit "${zone}" "${id}" "$@" + else + error "Unrecognized argument: ${cmd}" + cli_usage root-zone-config-subcommands + exit ${EXIT_ERROR} + fi fi ;; esac