Última atividade 1 month ago

nuno revisou este gist 1 month ago. Ir para a revisão

1 file changed, 58 insertions

gistfile1.txt(arquivo criado)

@@ -0,0 +1,58 @@
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 + }
Próximo Anterior