protected function runVclGenerate()
    {
        $config = Mage::getModel(
            'ecomdev_varnish/vcl_config_json',
            array('file' => $this->getArg('config'))
        );

        $block = $this->getConfigBlock();
        
        if ($version = $this->getArg('version')) {
            $block->setVersion($version);
        }
        
        if ($template = $this->getArg('template')) {
            $block->setTemplate($template);
        }

        $block->setConfig($config);
        
        $file = $this->getArg('file');

        if ($file) {
            $file = fopen($file, 'w');
        } else {
            $file = STDOUT;
        }

        fwrite($file, $block->toHtml());
    }