@@ -823,41 +823,51 @@ ssh-for-all *ARGS:
823823ssh-for-each HOSTNAMES * ARGS :
824824 colmena exec --verbose --parallel 0 --on {{ HOSTNAMES}} {{ ARGS}}
825825
826- # List machine ips based on regex pattern
827- ssh-list-ids PATTERN :
826+ # List machine id, ipv4, ipv6, name or region based on regex pattern
827+ ssh-list TYPE PATTERN :
828828 #!/ usr/ bin/ env nu
829- scj dump / dev/ stdout -c .ssh_config
830- | from json
831- | default " " Host
832- | default " " HostName
833- | where not ($it.Host =~ " .ipv(4|6)$" )
834- | where Host =~ " {{ PATTERN}} "
835- | get HostName
836- | str join " "
837-
838- # List machine ips based on regex pattern
839- ssh-list-ips PATTERN :
840- #!/ usr/ bin/ env nu
841- scj dump / dev/ stdout -c .ssh_config
842- | from json
843- | default " " Host
844- | default " " HostName
845- | where ($it.Host =~ " .ipv4$" )
846- | where Host =~ " {{ PATTERN}} "
847- | get HostName
848- | str join " "
849-
850- # List machine names based on regex pattern
851- ssh-list-names PATTERN :
852- #!/ usr/ bin/ env nu
853- scj dump / dev/ stdout -c .ssh_config
854- | from json
855- | default " " Host
856- | default " " HostName
857- | where not ($it.Host =~ " .ipv(4|6)$" )
858- | where Host =~ " {{ PATTERN}} "
859- | get Host
860- | str join " "
829+ const type = " {{ TYPE}} "
830+
831+ let sshCfg = (
832+ scj dump / dev/ stdout -c .ssh_config
833+ | from json
834+ | default " " Host
835+ | default " " HostName
836+ )
837+
838+ if ($type == " id" ) {
839+ $sshCfg
840+ | where not ($it.Host =~ " .ipv(4|6)$" )
841+ | where Host =~ " {{ PATTERN}} "
842+ | get HostName
843+ | str join " "
844+ } else if ($type == " ipv4" ) {
845+ $sshCfg
846+ | where ($it.Host =~ " .ipv4$" )
847+ | where Host =~ " {{ PATTERN}} "
848+ | get HostName
849+ | str join " "
850+ } else if ($type == " ipv6" ) {
851+ $sshCfg
852+ | where ($it.Host =~ " .ipv6$" )
853+ | where Host =~ " {{ PATTERN}} "
854+ | get HostName
855+ | str join " "
856+ } else if ($type == " name" ) {
857+ $sshCfg
858+ | where not ($it.Host =~ " .ipv(4|6)$" )
859+ | where Host =~ " {{ PATTERN}} "
860+ | get Host
861+ | str join " "
862+ } else if ($type == " region" ) {
863+ $sshCfg
864+ | where ($it.Host =~ " .ipv4$" )
865+ | where Host =~ " {{ PATTERN}} "
866+ | get Tag
867+ | str join " "
868+ } else {
869+ print " The TYPE must be one of: id, ipv4, ipv6, name or region"
870+ }
861871
862872# Start a local node for a specific env
863873start-node ENV :
0 commit comments