protected function main() { $this->init(); $remotePath = $this->input->getArgument('remote_path'); if ($this->input->getOption('id')) { if (!($node = Node::loadById($remotePath))) { throw new \Exception("No node exists with ID '{$remotePath}'."); } } else { if (!($node = Node::loadByPath($remotePath))) { throw new \Exception("No node exists at remote path '{$remotePath}'."); } } $result = $node->trash(); if ($result['success']) { $this->output->writeln("<info>Successfully trashed node at '{$remotePath}'</info>"); if ($this->output->isVerbose()) { $this->output->writeln(json_encode($result['data'])); } } else { $this->output->getErrorOutput()->writeln("<error>Failed to trash node at '{$remotePath}'</error>"); if ($this->output->isVerbose()) { $this->output->getErrorOutput()->writeln(json_encode($result['data'])); } } }
protected function main() { $this->init(); $remotePath = $this->input->getArgument('remote_path') ?: ''; if ($this->input->getOption('id')) { if (!($node = Node::loadById($remotePath))) { throw new \Exception("No node exists with ID '{$remotePath}'."); } } else { if (!($node = Node::loadByPath($remotePath))) { throw new \Exception("No node exists at remote path '{$remotePath}'."); } } if ($node->isFolder()) { throw new \Exception("Links can only be created for files."); } $response = $node->getMetadata(true); if ($response['success']) { if (isset($response['data']['tempLink'])) { $this->output->writeln($response['data']['tempLink']); } else { $this->output->getErrorOutput()->writeln("<error>Failed retrieving temporary link. Make sure you have permission.</error>"); } } else { $this->output->getErrorOutput()->writeln("<error>Failed retrieving metadata for node '{$remotePath}'</error>"); } }
protected function main() { $this->init(); $remotePath = $this->input->getArgument('remote_path'); $savePath = $this->input->getArgument('local_path') ?: getcwd(); if ($this->input->getOption('id')) { if (!($node = Node::loadById($remotePath))) { throw new \Exception("No node exists with ID '{$remotePath}'."); } } else { if (!($node = Node::loadByPath($remotePath))) { throw new \Exception("No node exists at remote path '{$remotePath}'."); } } $node->download($savePath, function ($result, $dest) { if ($result['success']) { $this->output->writeln("<info>Successfully downloaded file to '{$dest}'</info>"); } else { $this->output->getErrorOutput()->writeln("<error>Failed to download node to '{$dest}'</error>"); if ($this->output->isVerbose()) { $this->output->getErrorOutput()->writeln(json_encode($result['data'])); } } }); }
protected function main() { $this->init(); $id = $this->input->getArgument('id'); if (!($node = Node::loadById($id))) { throw new \Exception("No node exists with ID '{$id}'."); } $this->output->writeln($node->getPath()); }
protected function main() { $this->init(); $path = $this->input->getArgument('path') ?: ''; if ($this->input->getOption('id')) { if (!($node = Node::loadById($path))) { throw new \Exception("No node exists with ID '{$path}'."); } } else { if (!($node = Node::loadByPath($path))) { throw new \Exception("No node exists at remote path '{$path}'."); } } $this->output->writeln($this->convertFilesize($this->calculateTotalSize($node))); }
protected function main() { $this->initOnlineCommand(); $remotePath = $this->input->getArgument('remote_path'); if ($this->input->getOption('id')) { if (!($node = Node::loadById($remotePath))) { throw new \Exception("No node exists with ID '{$remotePath}'."); } } else { if (!($node = Node::loadByPath($remotePath))) { throw new \Exception("No node exists at remote path '{$remotePath}'."); } } if ($node->isFolder()) { throw new \Exception("Folder downloads are not currently supported."); } $node->download($this->output->getStream()); }
protected function main() { $this->init(); $path = $this->input->getArgument('path') ?: ''; if ($this->input->getOption('id')) { if (!($node = Node::loadById($path))) { throw new \Exception("No node exists with ID '{$path}'."); } } else { if (!($node = Node::loadByPath($path))) { throw new \Exception("No node exists at remote path '{$path}'."); } } if ($this->config['json.pretty']) { $this->output->writeln(json_encode($node, JSON_PRETTY_PRINT)); } else { $this->output->writeln(json_encode($node)); } }
protected function main() { $this->init(); $remotePath = $this->input->getArgument('remote_path'); if ($this->input->getOption('id')) { if (!($node = Node::loadById($remotePath))) { throw new \Exception("No node exists with ID '{$remotePath}'."); } } else { if (!($node = Node::loadByPath($remotePath))) { throw new \Exception("No node exists at remote path '{$remotePath}'."); } } $result = $node->restore(); if ($result['success']) { $this->output->writeln("Successfully restored node at '{$remotePath}': " . json_encode($result['data'])); } else { $this->output->writeln("Failed to restore node at '{$remotePath}': " . json_encode($result['data'])); } }
protected function main() { $this->init(); $path = $this->input->getArgument('path') ?: ''; $includeAssets = $this->input->getOption('assets') ? true : false; if ($this->input->getOption('id')) { if (!($node = Node::loadById($path))) { throw new \Exception("No node exists with ID '{$path}'."); } } else { if (!($node = Node::loadByPath($path))) { throw new \Exception("No node exists at remote path '{$path}'."); } } if ($this->input->getOption('markdown')) { $this->buildMarkdownTree($node, $includeAssets); } else { $this->buildAsciiTree($node, $includeAssets); } }
protected function main() { $this->init(); $this->clouddrive->getAccount()->authorize(); $remotePath = $this->input->getArgument('remote_path') ?: ''; $sort = Command::SORT_BY_NAME; if ($this->input->getOption('time')) { $sort = Command::SORT_BY_TIME; } if ($this->input->getOption('id')) { if (!($node = Node::loadById($remotePath))) { throw new \Exception("No node exists with ID '{$remotePath}'."); } } else { if (!($node = Node::loadByPath($remotePath))) { throw new \Exception("No node exists at remote path '{$remotePath}'."); } } if ($node->isFolder() || $this->input->getOption('assets')) { $this->listNodes($node->getChildren(), $sort); } else { $this->listNodes([$node], $sort); } }