using CommandLine;

namespace RolemasterDb.ImportTool;

[Verb("reimport-images",
    HelpText = "Regenerate critical table page and cell images, with optional SQLite metadata refresh.")]
public sealed class ReimportImagesOptions
{
    [Value(0, MetaName = "table", Required = false, HelpText = "The manifest slug of the critical table to refresh.")]
    public string? Table { get; set; }

    [Option('d', "db", HelpText = "Optional SQLite database path.")]
    public string? DatabasePath { get; set; }

    [Option('a', "all", Default = false, HelpText = "Refresh every enabled manifest entry instead of one table.")]
    public bool All { get; set; }

    [Option("update-metadata", Default = "true",
        HelpText =
            "Pass true or false to control whether SQLite source-image metadata is refreshed after regenerating artifacts.")]
    public string UpdateMetadataText { get; set; } = "true";

    public bool UpdateMetadata =>
        bool.TryParse(UpdateMetadataText, out var updateMetadata)
            ? updateMetadata
            : throw new InvalidOperationException("The --update-metadata option must be either 'true' or 'false'.");
}