Ejemplo n.º 1
0
 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']));
         }
     }
 }
Ejemplo n.º 2
0
 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>");
     }
 }
Ejemplo n.º 3
0
 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']));
             }
         }
     });
 }
Ejemplo n.º 4
0
 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());
 }
Ejemplo n.º 5
0
 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)));
 }
Ejemplo n.º 6
0
 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());
 }
Ejemplo n.º 7
0
 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));
     }
 }
Ejemplo n.º 8
0
 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']));
     }
 }
Ejemplo n.º 9
0
 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);
     }
 }
Ejemplo n.º 10
0
 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);
     }
 }