<?php
namespace nur\cli;

use nur\func;

class DynamicCommandMethod implements IDynamicCommand {
  function __construct($func) {
    $this->func = $func;
  }

  /** @var object */
  private $dest;

  function setDest($dest): void {
    if (!is_object($dest)) $dest = null;
    $this->dest = $dest;
  }

  function getCommands(): ?array {
    return null;
  }

  private $func;

  function getCommandDefs(string $command, bool $virtual): ?array {
    $func = $this->func;
    $func_args = [$command];
    func::check_func($func, $this->dest, $func_args);
    return func::call($func, ...$func_args);
  }
}
