gistfile1.txt
· 1.2 KiB · Text
Ham
#!/usr/bin/env bash
function cmd::inspect::on_load() {
flag::register --name
flag::register --type
}
function cmd::inspect::help() {
cat <<EOF
Usage: wgctl inspect --name <name> [--type <type>]
wgctl inspect <full-name>
Show detailed information for a single client.
Options:
--name <name> Client name
--type <type> Device type (optional, combines with --name)
Examples:
wgctl inspect --name phone-nuno
wgctl inspect --name nuno --type phone
EOF
}
function cmd::inspect::run() {
local name=""
local type=""
# Support positional argument: wgctl inspect phone-nuno
if [[ $# -gt 0 && "$1" != "--"* ]]; then
name="$1"
shift
fi
while [[ $# -gt 0 ]]; do
case "$1" in
--name) name="$2"; shift 2 ;;
--type) type="$2"; shift 2 ;;
--help) cmd::inspect::help; return ;;
*)
log::error "Unknown flag: $1"
cmd::inspect::help
return 1
;;
esac
done
if [[ -z "$name" ]]; then
log::error "Missing required flag: --name"
cmd::inspect::help
return 1
fi
name=$(peers::resolve_and_require "$name" "$type") || return 1
load_command list
cmd::list::run --name "$name"
}
| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | function cmd::inspect::on_load() { |
| 4 | flag::register --name |
| 5 | flag::register --type |
| 6 | } |
| 7 | |
| 8 | function cmd::inspect::help() { |
| 9 | cat <<EOF |
| 10 | Usage: wgctl inspect --name <name> [--type <type>] |
| 11 | wgctl inspect <full-name> |
| 12 | |
| 13 | Show detailed information for a single client. |
| 14 | |
| 15 | Options: |
| 16 | --name <name> Client name |
| 17 | --type <type> Device type (optional, combines with --name) |
| 18 | |
| 19 | Examples: |
| 20 | wgctl inspect --name phone-nuno |
| 21 | wgctl inspect --name nuno --type phone |
| 22 | EOF |
| 23 | } |
| 24 | |
| 25 | function cmd::inspect::run() { |
| 26 | local name="" |
| 27 | local type="" |
| 28 | |
| 29 | # Support positional argument: wgctl inspect phone-nuno |
| 30 | if [[ $# -gt 0 && "$1" != "--"* ]]; then |
| 31 | name="$1" |
| 32 | shift |
| 33 | fi |
| 34 | |
| 35 | while [[ $# -gt 0 ]]; do |
| 36 | case "$1" in |
| 37 | --name) name="$2"; shift 2 ;; |
| 38 | --type) type="$2"; shift 2 ;; |
| 39 | --help) cmd::inspect::help; return ;; |
| 40 | *) |
| 41 | log::error "Unknown flag: $1" |
| 42 | cmd::inspect::help |
| 43 | return 1 |
| 44 | ;; |
| 45 | esac |
| 46 | done |
| 47 | |
| 48 | if [[ -z "$name" ]]; then |
| 49 | log::error "Missing required flag: --name" |
| 50 | cmd::inspect::help |
| 51 | return 1 |
| 52 | fi |
| 53 | |
| 54 | name=$(peers::resolve_and_require "$name" "$type") || return 1 |
| 55 | |
| 56 | load_command list |
| 57 | cmd::list::run --name "$name" |
| 58 | } |