using System.CommandLine;

namespace ZB.MOM.WW.ScadaBridge.CLI.Commands;

/// <summary>
/// Factory methods for the global CLI options. Centralising option construction keeps
/// validation rules (e.g. the accepted <c>--format</c> values) in one place and makes
/// them testable without standing up the whole command tree.
/// </summary>
internal static class CliOptions
{
    /// <summary>
    /// Creates the global <c>--format</c> option. The option deliberately has no
    /// <c>DefaultValueFactory</c> — format precedence (explicit flag → config/env →
    /// <c>"json"</c>) is resolved by <see cref="CommandHelpers.ResolveFormat"/>, which
    /// needs to distinguish an absent flag. The accepted values are constrained so a
    /// typo (e.g. <c>--format tabel</c>) is rejected with a clear parse error rather
    /// than silently falling through to JSON.
    /// </summary>
    /// <returns>The configured <c>--format</c> option constrained to "json" or "table".</returns>
    internal static Option<string> CreateFormatOption()
    {
        var formatOption = new Option<string>("--format")
        {
            Description = "Output format (json or table)",
            Recursive = true,
        };
        formatOption.AcceptOnlyFromAmong("json", "table");
        return formatOption;
    }
}
