edit:add-var digall~ {|@argv| use re use str use framagit.org/benjamin.vaudour/elv-lib/mods/common use framagit.org/benjamin.vaudour/elv-lib/mods/format use framagit.org/benjamin.vaudour/elv-lib/mods/list var default_records = [ A AAAA CNAME PTR TXT MX SRV NAPTR NS SOA ] var records servers = [] [] var flags = [ +noall +answer ] var domains use_dig = [] $true fn init { if (and (list:is-not-empty $argv) (eq $argv[0] -d)) { set use_dig argv = $false $argv[1..] } each {|e| if (eq $e[0] +) { set @flags = $@flags $e } elif (eq $e[0] @) { set @servers = $@servers $e } elif (list:contains $e $default_records) { set @records = $@records $e } else { set @domains = $@domains $e } } $argv if (list:is-empty $records) { set records = $default_records } } fn format {|results| re:awk {|_ @args| put [ $args[0] (all $args[2..]) ] } $results | list:remove-duplicate | list:sort {|l1 l2| var c = (compare $l1[0] $l2[0]) if (== $c 0) { set c = (compare $l1[2] $l2[2]) } put $c } | each {|e| str:join ' ' $e} | format:tabulate } fn drillr {|d @args| var @results = (peach {|r| e:drill $@args $r $d | list:filter {|e| and (> (count $e) 2) (not-eq $e[..2] ';;') } } $records) format $results } fn digr {|d @args| var @results = (peach {|r| e:dig $@args $r $d $@flags } $records) format $results } fn req {|d @args| common:cexec $use_dig { digr $d $@args } { drillr $d $@args } } fn digs {|s d| put (echo (styled $s bright-yellow)) req $d $s } fn digd {|d| var @results = (echo (styled 'Domaine: '$d bright-green)) if (list:is-not-empty $servers) { each {|s| set @results = $@results (digs $s $d) } $servers } else { set @results = $@results (req $d) } echo (str:join "\n" $results) } init peach $digd~ $domains }