export class ExecutionResult {
    protected stdout: string[] = []
    protected stderr: string[] = []
    protected mixed: string[] = []
    public exitCode?: number

    out(data: any) {
        this.stdout = this.stdout.concat(`${data}`.split('\n'))
        this.mixed = this.mixed.concat(`${data}`.split('\n'))
    }

    error(data: any) {
        this.stderr = this.stderr.concat(`${data}`.split('\n'))
        this.mixed = this.mixed.concat(`${data}`.split('\n'))
    }

    exit(code: number) {
        this.exitCode = code
    }

    public wasSuccessful(): boolean {
        return this.exitCode === 0
    }

    public get combinedOutput(): string[] {
        return this.mixed.filter(Boolean)
    }

    public get standardOutput(): string[] {
        return this.stdout.filter(Boolean)
    }

    public get errorOutput(): string[] {
        return this.stderr.filter(Boolean)
    }
}
