nu: Add --server argument to dns command

This commit is contained in:
2025-08-28 13:59:00 +02:00
parent 8517bc121c
commit 18a93fe079

View File

@ -47,9 +47,15 @@ def "m daemon is-running" [
} }
def dns [ def dns [
--server (-s): string,
name: string, name: string,
] { ] {
nslookup $name | # HACK: turn the optional argument into a list. not sure how to pass it to nslookup otherwise.
let server = ([$server] | compact)
nslookup $name ...$server |
lines |
skip until { |line| $line =~ answer } |
parse -r "Address:\\s(?<ipv4>\\d+\\.\\d+\\.\\d+\\.\\d+)|Address:\\s(?<ipv6>[\\d:a-z]+)" | parse -r "Address:\\s(?<ipv4>\\d+\\.\\d+\\.\\d+\\.\\d+)|Address:\\s(?<ipv6>[\\d:a-z]+)" |
each { |row| each { |row|
if $row.ipv4 != "" { if $row.ipv4 != "" {