- Replace 6 compound Likert questions with 12 atomic ones grouped by dimension (syntax, expressiveness, data/IO, errors, overall); drop free-form question. Responses now stored as ints, not strings. - Back-compat layer maps legacy keys to new dimensions so existing results still render. - Parallelize run-all with ThreadPoolExecutor (configurable workers) and add a thread-safe min-request-interval rate limiter to the Anthropic provider. - Add new tasks: path_normalizer, todo_manager, currency_converter, locale_weather_url, network_info_parser, url_normalizer.
87 lines
2.6 KiB
TOML
87 lines
2.6 KiB
TOML
name = "network_info_parser"
|
|
category = "pipeline"
|
|
mode = "convert"
|
|
description = """
|
|
Parse network interface configuration from stdin (in "ip addr show" format)
|
|
and extract a summary of each interface.
|
|
|
|
For each interface block, output a line:
|
|
IFACE: <name> IP: <ipv4_addr> MASK: /<prefix_len>
|
|
|
|
An interface block starts with a line like:
|
|
2: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 ...
|
|
and contains inet lines like:
|
|
inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0
|
|
|
|
If an interface has no inet line, output:
|
|
IFACE: <name> IP: none MASK: none
|
|
|
|
Skip the loopback interface (lo).
|
|
"""
|
|
|
|
bash_source = '''
|
|
#!/bin/bash
|
|
|
|
current_iface=""
|
|
found_ip=""
|
|
found_mask=""
|
|
|
|
flush_iface() {
|
|
if [[ -n "$current_iface" && "$current_iface" != "lo" ]]; then
|
|
if [[ -n "$found_ip" ]]; then
|
|
echo "IFACE: $current_iface IP: $found_ip MASK: /$found_mask"
|
|
else
|
|
echo "IFACE: $current_iface IP: none MASK: none"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
while IFS= read -r line || [[ -n "$line" ]]; do
|
|
# Detect interface line: starts with a number followed by colon
|
|
if echo "$line" | grep -qE '^[0-9]+:'; then
|
|
flush_iface
|
|
current_iface=$(echo "$line" | awk -F: '{print $2}' | sed 's/^[[:space:]]*//' | awk '{print $1}')
|
|
found_ip=""
|
|
found_mask=""
|
|
fi
|
|
|
|
# Detect inet line (IPv4 only, not inet6)
|
|
if echo "$line" | grep -qE '^[[:space:]]+inet [0-9]'; then
|
|
ip_cidr=$(echo "$line" | awk '{print $2}')
|
|
found_ip=$(echo "$ip_cidr" | cut -d/ -f1)
|
|
found_mask=$(echo "$ip_cidr" | cut -d/ -f2)
|
|
fi
|
|
done
|
|
|
|
flush_iface
|
|
'''
|
|
|
|
[[test_cases]]
|
|
description = "Two interfaces with IPs"
|
|
stdin = """1: lo: <LOOPBACK,UP> mtu 65536
|
|
inet 127.0.0.1/8 scope host lo
|
|
2: eth0: <BROADCAST,MULTICAST,UP> mtu 1500
|
|
inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0
|
|
3: wlan0: <BROADCAST,MULTICAST,UP> mtu 1500
|
|
inet 10.0.0.42/16 brd 10.0.255.255 scope global wlan0"""
|
|
expected_stdout = """IFACE: eth0 IP: 192.168.1.100 MASK: /24
|
|
IFACE: wlan0 IP: 10.0.0.42 MASK: /16"""
|
|
|
|
[[test_cases]]
|
|
description = "Interface with no IP"
|
|
stdin = """1: lo: <LOOPBACK,UP> mtu 65536
|
|
inet 127.0.0.1/8 scope host lo
|
|
2: eth0: <BROADCAST,MULTICAST,UP> mtu 1500
|
|
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500
|
|
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0"""
|
|
expected_stdout = """IFACE: eth0 IP: none MASK: none
|
|
IFACE: docker0 IP: 172.17.0.1 MASK: /16"""
|
|
|
|
[[test_cases]]
|
|
description = "Single interface"
|
|
stdin = """1: lo: <LOOPBACK,UP> mtu 65536
|
|
inet 127.0.0.1/8 scope host lo
|
|
2: enp3s0: <BROADCAST,MULTICAST,UP> mtu 9000
|
|
inet 10.10.10.5/8 brd 10.255.255.255 scope global enp3s0"""
|
|
expected_stdout = "IFACE: enp3s0 IP: 10.10.10.5 MASK: /8"
|