:- dynamic fw_rule/2.

:- use_module(bgp, [
    create_firewall/0]).

print_warnings([]).
print_warnings([W|Ws]) :- format("Warning: ~w~n", [W]), print_warnings(Ws).

print_warnings :-
  findall(W, bgp:warning(W), BgpWs),
  findall(W, firewall:warning(W), FwWs),
  append(BgpWs, FwWs, Ws),
  writeln(BgpWs),
  writeln(FwWs),
  writeln(Ws),
  length(Ws, L),
  ( L > 0
  ->format("Found ~w warning(s):~n", [L]),
    print_warnings(Ws)
  ; format("No warnings!~n")
  ).

main :-
  print_warnings,
  bgp:create_firewall(),
  bgp:bird_config(BirdDict),
  yaml_write(current_output, BirdDict).