#ifndef COMPILER_H
#define COMPILER_H

#include "probe.h"
#include "typecheck.h"

typedef struct {
  char** argv;
  size_t argc;
  const char* subtitle_output;
  bool clip_subtitles;
  double clip_duration;
} StagedCommand;

typedef struct {
  Arena arena;
  char** argv;
  size_t argc;
  StagedCommand* stages;
  size_t stage_count;
  size_t stage_capacity;
  const char** temporary_paths;
  size_t temporary_count;
  size_t temporary_capacity;
  const char* filter_complex;
  const char* shell_command;
} CompiledCommand;

bool compile_program(const Program* program, const TypedProgram* typed, ProbeCache* probes,
                     const char* output_path, CompiledCommand* out, Error* error);
void compiled_command_destroy(CompiledCommand* command);
bool execute_command(const CompiledCommand* command, int* exit_code, Error* error);

#endif