import sys
import yaml
from pathlib import Path
from pyshield.exporters import BaseExporter

class YamlExporter(BaseExporter):
    def export(self):
        # yaml_export.formatting: indent: 2, safe_dump: true
        yaml_content = yaml.safe_dump(self.report, indent=2, sort_keys=False)
        
        if self.output_path:
            out_file = Path(self.output_path).resolve()
            out_file.write_text(yaml_content)
            print(f"Report saved to {out_file}", file=sys.stderr)
        else:
            print(yaml_content)
