:- use_module(library(format)).
:- use_module(library(lists)).

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

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

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

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