public function clear()
    {
        $this->out('<info>' . __d('cake_resque', 'Clearing queues') . '</info>');

        // List of all queues
        $queues = array_unique(CakeResque::getQueues());
        if (empty($queues)) {
            $this->out(__d('cake_resque', 'There is no queues to clear'));

            return false;
        }

        $queueIndex = [];
        if (isset($this->args[0])) {
            if (in_array($this->args[0], $queues)) {
                $queueIndex[] = array_search($this->args[0], $queues) + 1;
            }
        } else {
            if (!$this->params['all'] && count($queues) > 1) {
                $this->out(__d('cake_resque', 'Queues list') . ':');
                $i = 1;
                foreach ($queues as $queue) {
                    $this->out(sprintf("    [%3d] - %-'.20s<bold>%'.9s</bold> jobs", $i++, $queue, number_format(CakeResque::getQueueSize($queue))));
                }

                $options = range(1, $i - 1);

                if ($i > 2) {
                    $this->out('    [all] - ' . __d('cake_resque', 'Clear all queues'));
                    $options[] = 'all';
                }

                $in = $this->in(__d('cake_resque', 'Queue to clear') . ': ', $options);
                if ($in == 'all') {
                    $queueIndex = range(1, count($queues));
                } else {
                    $queueIndex[] = $in;
                }

            } else {
                $queueIndex = range(1, count($queues));
            }
        }

        foreach ($queueIndex as $index) {
            $queue = $queues[ $index - 1 ];

            $this->out(__d('cake_resque', 'Clearing {0} ... ', $queue), 0);

            $cleared = CakeResque::clearQueue($queue);

            if ($cleared) {
                CakeResque::removeQueue($queue);
                $this->out('<success>' . __d('cake_resque', 'Done') . '</success>');
            } else {
                $this->out('<error>' . __d('cake_resque', 'Fail') . '</error>');
            }
        }

        return true;
    }