package de.gecheckt.pdf.umbenenner.adapter.in.cli;

import de.gecheckt.pdf.umbenenner.application.port.in.BatchRunOutcome;
import de.gecheckt.pdf.umbenenner.application.port.in.BatchRunProcessingUseCase;
import de.gecheckt.pdf.umbenenner.domain.model.BatchRunContext;

/**
 * CLI command adapter for batch processing scheduling.
 * <p>
 * This class acts as the inbound technical entry point that exclusively delegates
 * to the application layer's batch processing use case via the {@link BatchRunProcessingUseCase}
 * interface. It receives the batch run outcome and makes it available to the Bootstrap layer
 * for exit code determination and logging.
 * <p>
 * Returns {@link BatchRunOutcome} to allow Bootstrap to systematically derive exit codes.
 * Accepts {@link BatchRunContext} and passes it to the use case,
 * enabling run ID and timing tracking throughout the batch cycle.
 * <p>
 * Dependency inversion achieved - this adapter depends only on the
 * BatchRunProcessingUseCase interface, not on any concrete implementation. Bootstrap
 * is responsible for injecting the appropriate use case implementation.
 */
public class SchedulerBatchCommand {

    private final BatchRunProcessingUseCase useCase;

    /**
     * Creates a new SchedulerBatchCommand with the given use case.
     *
     * @param useCase the batch processing use case to delegate to
     */
    public SchedulerBatchCommand(BatchRunProcessingUseCase useCase) {
        this.useCase = useCase;
    }

    /**
     * Executes the batch processing command with the given run context.
     * <p>
     * Delegates to the use case with the batch run context and returns its structured outcome.
     *
     * @param context the technical context for this batch run
     * @return {@link BatchRunOutcome} describing the result of batch processing
     */
    public BatchRunOutcome run(BatchRunContext context) {
        return useCase.execute(context);
    }
}