private function askSourcePath() { // ask path $root = $this->filesystems->getConfig($this->option('source'), 'root'); $path = $this->ask("From which path do you want to select?<comment> {$root}</comment>"); $this->line(''); // ask file $filesystem = $this->filesystems->get($this->option('source')); $contents = $filesystem->listContents($path); $files = []; foreach ($contents as $file) { if ($file['type'] == 'dir') { continue; } $files[] = $file['basename']; } if (empty($files)) { $this->info('No backups were found at this path.'); return; } $rows = []; foreach ($contents as $file) { if ($file['type'] == 'dir') { continue; } $rows[] = [$file['basename'], $file['extension'], $this->formatBytes($file['size']), date('D j Y H:i:s', $file['timestamp'])]; } $this->info('Available database dumps:'); $this->table(['Name', 'Extension', 'Size', 'Created'], $rows); $filename = $this->autocomplete("Which database dump do you want to restore?", $files); $this->input->setOption('sourcePath', "{$path}/{$filename}"); }
/** * Execute the console command. * * @throws \LogicException * @throws \BigName\BackupManager\Filesystems\FilesystemTypeNotSupported * @throws \BigName\BackupManager\Config\ConfigFieldNotFound * @throws \BigName\BackupManager\Config\ConfigNotFoundForConnection * @return void */ public function fire() { if ($this->isMissingArguments()) { $this->displayMissingArguments(); $this->promptForMissingArgumentValues(); $this->validateArguments(); } $filesystem = $this->filesystems->get($this->option('source')); $contents = $filesystem->listContents($this->option('path')); $rows = []; foreach ($contents as $file) { if ($file['type'] == 'dir') { continue; } $rows[] = [$file['basename'], $file['extension'], $this->formatBytes($file['size']), date('D j Y H:i:s', $file['timestamp'])]; } $this->table(['Name', 'Extension', 'Size', 'Created'], $rows); }