#!/usr/bin/env bash # ============================================ # Lifecycle # ============================================ function cmd::config::on_load() { flag::register --name flag::register --type } # ============================================ # Help # ============================================ function cmd::config::help() { cat < Show the WireGuard config file for a client. Options: --name Client name (e.g. phone-nuno) Examples: wgctl config --name phone-nuno wgctl config --name laptop-nuno EOF } # ============================================ # Run # ============================================ function cmd::config::run() { local name="" local type="" while [[ $# -gt 0 ]]; do case "$1" in --name) name="$2"; shift 2 ;; --type) type="$2"; shift 2 ;; --help) cmd::config::help; return ;; *) log::error "Unknown flag: $1" cmd::config::help return 1 ;; esac done if [[ -z "$name" ]]; then log::error "Missing required flag: --name" return 1 fi name=$(peers::resolve_and_require "$name" "$type") || return 1 local conf conf="$(ctx::clients)/${name}.conf" log::section "Client Config: ${name}" cat "$conf" }