protected function showDialogChecklist(array $options, $text = 'Choose item(s)')
    {
        $width = 80;
        $height = 20;
        $listHeight = 20;
        $command = sprintf(
            'dialog --separate-output --checklist %s %d %d %d',
            escapeshellarg($text),
            $height,
            $width,
            $listHeight
        );
        foreach ($options as $tag => $option) {
            $command .= sprintf(' %s %s off', escapeshellarg($tag), escapeshellarg($option));
        }

        $dialogRc = file_get_contents(CLI_ROOT . '/resources/console/dialogrc');
        $dialogRcFile = $this->config()->getWritableUserDir() . '/dialogrc';
        if ($dialogRc !== false && (file_exists($dialogRcFile) || file_put_contents($dialogRcFile, $dialogRc))) {
            putenv('DIALOGRC=' . $dialogRcFile);
        }

        $pipes = [2 => null];
        $process = proc_open($command, [
            2 => array('pipe', 'w'),
        ], $pipes);

        // Wait for and read result.
        $result = array_filter(explode("\n", trim(stream_get_contents($pipes[2]))));

        // Close handles.
        if (is_resource($pipes[2])) {
            fclose($pipes[2]);
        }

        proc_close($process);

        $this->stdErr->writeln('');

        return $result;
    }