#!/bin/bash cliHandlePeerCommands() { local action="$initial_command2" local arg1="$initial_command3" local arg2="$initial_command4" local arg3="$initial_command5" local arg4="$initial_command6" case "$action" in ""|help) cliShowPeerHelp ;; list) peerList ;; get) [[ -z "$arg1" ]] && { isNotice "Usage: peer get "; return; } peerGet "$arg1" ;; add) # peer add [k=v] [k=v] # Up to two k=v pairs from initial_command5..6 — covers backup-channel's # hostname + loc_idx, which is the only kind that's wired today. [[ -z "$arg1" || -z "$arg2" ]] && { isNotice "Usage: peer add [key=value ...]"; return; } peerAdd "$arg1" "$arg2" "$arg3" "$arg4" ;; remove|rm|delete) [[ -z "$arg1" ]] && { isNotice "Usage: peer remove "; return; } peerRemove "$arg1" ;; check) if [[ -z "$arg1" ]]; then peerCheckAll else peerCheckReachable "$arg1" fi ;; *) isNotice "Invalid peer action: $action" cliShowPeerHelp ;; esac }