/*
 * Copyright (C) Sapphirecode - All Rights Reserved
 * This file is part of console-app which is released under MIT.
 * See file 'LICENSE' for full license details.
 * Created by Timo Hocker <timo@scode.ovh>, October 2020
 */

import { List } from 'enquirer';
import { InteractiveSubSource } from './InteractiveSubSource';

export class ArraySubSource extends InteractiveSubSource {
  protected condition ():boolean {
    return this.val.type_validation.option_type === 'array';
  }

  protected async run ():Promise<void> {
    await this.val.assign_arg (
      this.opt,
      await new List ({
        message: this.get_message (),
        default: this.opt.default
      })
        .run ()
    );
  }
}