using System.Text;

namespace Umbraco.Cms.Infrastructure.ModelsBuilder.Building;

internal static class TextHeaderWriter
{
    /// <summary>
    ///     Outputs an "auto-generated" header to a string builder.
    /// </summary>
    /// <param name="sb">The string builder.</param>
    /// <param name="includeVersion">Flag indicating whether the tool version number should be included in the output.</param>
    public static void WriteHeader(StringBuilder sb, bool includeVersion)
    {
        sb.Append("//------------------------------------------------------------------------------\n");
        sb.Append("// <auto-generated>\n");
        sb.Append("//   This code was generated by a tool.\n");
        sb.Append("//\n");

        if (includeVersion)
        {
            sb.AppendFormat("//    Umbraco.ModelsBuilder.Embedded v{0}\n", ApiVersion.Current.Version);
        }
        else
        {
            sb.Append("//    Umbraco.ModelsBuilder.Embedded\n");
        }

        sb.Append("//\n");
        sb.Append("//   Changes to this file will be lost if the code is regenerated.\n");
        sb.Append("// </auto-generated>\n");
        sb.Append("//------------------------------------------------------------------------------\n");
        sb.Append("\n");
    }
}
