protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $baseDir = $input->getOption('search-directory') ?: $this->getParameter('template_dir');
     // Remove trailing slash
     if (substr($baseDir, -1) === '/') {
         $baseDir = substr($baseDir, 0, -1);
     }
     $env = $input->getArgument('env');
     $dir = sprintf('%s/%s', $baseDir, $env);
     if (!file_exists($dir)) {
         throw new \RuntimeException(sprintf('The directory <error>"%s"</error> does not exist, you\'ll need to download the templates locally first', $dir));
     }
     // TODO Use Finder Component
     $searchRevisions = $input->getOption('search-revisions');
     $this->templates = array_map(function ($basePath) use($searchRevisions) {
         $templateRevisions = glob(sprintf('%s/*', escapeshellcmd($basePath)));
         $basePathLen = strlen($basePath) + 1;
         $revisionArray = array_combine(array_map(function ($revision) use($basePathLen) {
             return substr($revision, $basePathLen);
         }, $templateRevisions), $templateRevisions);
         ksort($revisionArray, SORT_NUMERIC);
         $revisionsToSearch = $searchRevisions ? $revisionArray : array(end($revisionArray));
         return array_map(function ($fileName) {
             $data = file_get_contents($fileName);
             return json_decode($data, true);
         }, $revisionsToSearch);
     }, glob(sprintf('%s/*', escapeshellcmd($dir))));
     $output->writeln(sprintf('Searching templates from %s for %s', $env, $input->getArgument('search')));
 }
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->client = $this->getSailThruClient($input->getArgument('env'));
     if (!file_exists($input->getArgument('file'))) {
         throw new \RuntimeException(sprintf('The file %s does not exist'));
     }
     $filesize = filesize($input->getArgument('file'));
     $output->writeln(sprintf('The file is %d bytes', $filesize));
     if (floor($filesize / 1024) > $input->getArgument('max-size')) {
         $tmpDir = sys_get_temp_dir() . '/sailthru';
         $filePrefix = 'chunk';
         if (is_dir($tmpDir)) {
             // Clean it out
         } else {
             mkdir($tmpDir);
         }
         // TODO Make cross platform
         exec(sprintf('split --line-bytes=%dm --verbose %s %s/%s 2>&1', $input->getArgument('max-size'), $input->getArgument('file'), $tmpDir, $filePrefix));
         // TODO Use Finder Component
         $this->files = glob(sprintf('%s/%s*', $tmpDir, $filePrefix));
         $output->writeln(sprintf('The file will be uploaded in %d chunks', count($this->files)));
     } else {
         $this->files = array($input->getArgument('file'));
     }
 }
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     if (!file_exists($input->getArgument('file'))) {
         throw new \RuntimeException(sprintf('The file %s does not exist'), $input->getArgument('file'));
     }
     $this->client = $this->getSailThruClient($input->getArgument('env'));
 }
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->status = $input->getArgument('status');
     if (!in_array($this->status, self::$validStatuses)) {
         throw new \InvalidArgumentException(sprintf('%s is not a valid status, only %s', $this->status, implode(', ', self::$validStatuses)));
     }
     $this->client = $this->getSailThruClient($input->getArgument('env'));
 }
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->client = $this->getSailThruClient($input->getArgument('env'));
     $this->dateStart = new \DateTime($input->getArgument('date_start'));
     $this->dateEnd = new \DateTime($input->getArgument('date_end'));
     $this->dateDiff = $this->dateStart->diff($this->dateEnd);
     $fileName = sprintf('%s/SailThruReports/%s.csv', sys_get_temp_dir(), $input->getArgument('template'));
     $output->writeln(sprintf('Creating file: %s', $fileName));
     $this->fh = fopen($fileName, 'w+');
 }
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->client = $this->getSailThruClient($input->getArgument('env'));
     $this->vars = array();
     if ($vars = $input->getArgument('vars')) {
         $this->vars = array_merge($this->vars, json_decode($vars, true));
     }
     foreach ($input->getOption('files') as $file) {
         $this->vars = array_merge($this->vars, json_decode(file_get_contents($file), true));
     }
 }
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $baseDir = $input->getOption('user-directory') ?: $this->getParameter('user_dir');
     // Remove trailing slash
     if (substr($baseDir, -1) === '/') {
         $baseDir = substr($baseDir, 0, -1);
     }
     $this->env = $input->getArgument('env');
     $this->dir = sprintf('%s/%s/%s', $baseDir, $this->env, $input->getArgument('email'));
     $this->createDirectory($output, $this->dir);
     $this->client = $this->getSailThruClient($input->getArgument('env'));
 }
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $baseDir = $input->getOption('download-directory') ?: $this->getParameter('template_dir');
     // Remove trailing slash
     if (substr($baseDir, -1) === '/') {
         $baseDir = substr($baseDir, 0, -1);
     }
     $this->env = $input->getArgument('env');
     $this->dir = sprintf('%s/%s', $baseDir, $this->env);
     $this->createDirectory($output, $this->dir);
     $this->client = $this->getSailThruClient($input->getArgument('env'));
     $output->writeln(sprintf('Downloading templates from <error>%s</error> into <comment>%s</comment>', $this->env, $this->dir));
 }
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->client = $this->getSailThruClient($input->getArgument('env'));
     $this->lists = array();
     // Check to see if we are using regexes
     if ($input->getOption('regex')) {
         // Loop over all of the includes on the from client
         foreach ($this->client->getlists()['lists'] as $list) {
             // If it matches, then add it to the lists to be deleted
             if (preg_match($input->getArgument('list'), $list['name'])) {
                 $this->lists[] = $list['name'];
             }
         }
     } else {
         // Just add the passed in list
         $this->lists[] = $input->getArgument('list');
     }
 }
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->fromClient = $this->getSailThruClient($input->getArgument('from-env'));
     $this->toClient = $this->getSailThruClient($input->getArgument('to-env'));
     // Check to see if we are using regexes
     if ($input->getOption('regex')) {
         // Loop over all of the includes on the from client
         foreach ($this->fromClient->getIncludes()['includes'] as $include) {
             // If it matches, then add it to the list to be copied
             if (preg_match($input->getArgument('include'), $include['name'])) {
                 $this->includes[] = $include['name'];
             }
         }
     } else {
         // Just add the passed in include
         $this->includes[] = $input->getArgument('include');
     }
 }
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->client = $this->getSailThruClient($input->getArgument('env'));
 }
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     $this->api = $this->getSailThruClient('prod');
 }