feat: complete professional cli with full lifecycle and tests

This commit is contained in:
Fredrick Amnehagen 2026-02-05 11:37:29 +01:00
parent a7d97227d3
commit 34ba255024
12 changed files with 112 additions and 9 deletions

View file

@ -38,16 +38,17 @@ class RouterManager:
def list(self):
# Get sections
# Use -n to prevent SSH from consuming stdin if we were in a loop (here we use split)
res = self.client.run("uci show firewall | grep '=redirect' | cut -d. -f2 | cut -d= -f1 | sort | uniq")
sections = res.stdout.strip().split('\n')
results = []
for section in sections:
if not section: continue
name = self.client.run(f"uci get firewall.{section}.name", capture=True).stdout.strip()
proto = self.client.run(f"uci get firewall.{section}.proto", capture=True).stdout.strip()
port = self.client.run(f"uci get firewall.{section}.src_dport", capture=True).stdout.strip()
dest = self.client.run(f"uci get firewall.{section}.dest_ip", capture=True).stdout.strip()
name = self.client.run(f"uci get firewall.{section}.name").stdout.strip()
proto = self.client.run(f"uci get firewall.{section}.proto").stdout.strip()
port = self.client.run(f"uci get firewall.{section}.src_dport").stdout.strip()
dest = self.client.run(f"uci get firewall.{section}.dest_ip").stdout.strip()
results.append({
"section": section,
"name": name,
@ -55,4 +56,4 @@ class RouterManager:
"port": port,
"dest": dest
})
return results
return results