proc listmap {commandlist list} {
    tailcall lmap item $list $commandlist
}

proc pipe_webpub {} {
pipeset subpipe % .= {
    pipeswitch {
        pipecase \
            .= val [lindex $switchargs 0] {|
            >} {string trimright $data .} |server> {split $data .} {|
            >} 'webpub.net'.= {
                join [lrange $data 1 2] .
            } {|
            >} {
                list type internal server $server
            }
            
        pipecase .= val [list type external server [lindex $switchargs 0]]
        #val [list type external server [lindex $switchargs 0]]
        
    } $ns
} <ns|

return $subpipe
}

proc pipe_nameserverlist {} {
    return [list % {val $domain} |>  {runout -n dig $data  ns +short} |> linelist |> {listmap {{*}[pipe_webpub] $item} $data} <domain|]
}

#{*}[pipe_nameserverlist] precisium.com.au


proc nameserverlist {domain} {
    tailcall {*}[pipe_nameserverlist] $domain
}
proc nameserverdisplay {domain} {
    return [list % val $domain |> {{*}[pipe_nameserverlist] $data } |> lsort]
}

puts stdout "command available: nameserverlist <domain>"