package de.gecheckt.pdf.umbenenner.bootstrap.startup;

import java.util.Objects;
import java.util.Optional;

/**
 * Immutable value object carrying the successfully parsed CLI startup arguments.
 * <p>
 * Produced by {@link CliArgumentParser} when command-line arguments are syntactically
 * valid. Bootstrap uses this record to determine the startup mode (GUI or headless)
 * and whether a custom configuration file path was supplied via {@code --config <path>}.
 * <p>
 * A {@code StartupArguments} instance is always consistent: it is only created when
 * parsing succeeded. Parse failures are represented by
 * {@link StartupArgumentsParseResult.Invalid} instead.
 *
 * @param mode       the determined startup mode; never {@code null}
 * @param configPath the configuration file path supplied via {@code --config <path>},
 *                   or empty if the option was absent from the command line
 */
public record StartupArguments(StartupMode mode, Optional<String> configPath) {

    /**
     * Compact canonical constructor enforcing non-null invariants.
     *
     * @param mode       the startup mode; must not be {@code null}
     * @param configPath the optional configuration path; must not be {@code null}
     * @throws NullPointerException if {@code mode} or {@code configPath} is {@code null}
     */
    public StartupArguments {
        Objects.requireNonNull(mode, "mode must not be null");
        Objects.requireNonNull(configPath, "configPath must not be null");
    }
}
