public function buildCommand($task, $slug = null)
    {
        // Build the task instance
        try {
            $instance = $this->modulable->buildTask($task);
        } catch (TaskCompositionException $exception) {
            $instance = null;
        }

        // Get the command name
        $name = $instance ? $instance->getName() : null;
        $command = $this->modulable->findQualifiedName($name, 'commands');

        // If no command found, use BaseTaskCommand or task name
        if ($command === BaseTaskCommand::class) {
            $name = is_string($task) ? $task : $name;
            $command = $this->modulable->findQualifiedName($name, 'commands');
        }

        /** @var AbstractCommand $command */
        $command = new $command($instance, $slug);
        $command->setContainer($this->container);

        return $command;
    }