import type {
  ContentExpectations,
  RawContentExpectations,
  RawValueExpectation,
  ValueExpectation,
} from "../../expect/types";
import type { ResolvedTargetBase } from "../../types";

export interface CommandDefaultsConfig {
  cwd?: string;
  maxOutputBytes?: string;
}

export interface CommandTargetConfig {
  args?: string[];
  cwd?: string;
  env?: Record<string, string>;
  exec: string;
  maxOutputBytes?: string;
}

export interface RawCommandExpectConfig {
  durationMs?: RawValueExpectation;
  exitCode?: number[];
  stderr?: RawContentExpectations;
  stdout?: RawContentExpectations;
}

export interface ResolvedCommandConfig {
  args: string[];
  cwd: string;
  env: Record<string, string>;
  exec: string;
  maxOutputBytes: number;
}

export interface ResolvedCommandExpectConfig {
  durationMs?: ValueExpectation;
  exitCode: number[];
  stderr?: ContentExpectations;
  stdout?: ContentExpectations;
}

export interface ResolvedCommandTarget extends ResolvedTargetBase {
  cmd: ResolvedCommandConfig;
  expect?: ResolvedCommandExpectConfig;
  group: string;
  intervalMs: number;
  name: null | string;
  rawExpect?: RawCommandExpectConfig;
  timeoutMs: number;
  type: "cmd";
}
