From 59111e61adc1600bd0c728abba4c117f152da03c Mon Sep 17 00:00:00 2001 From: Jason Judge Date: Mon, 1 Jun 2020 18:28:37 +0100 Subject: [PATCH] Update for Laravel 7 --- README.md | 8 ++++++++ composer.json | 2 +- src/Console/Commands/ListStorage.php | 14 +++++++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8172abd..03739b1 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,10 @@ $ php artisan storage:ls --disk=s3 # or $ php artisan storage:ls -d s3 + +# or + +$ php artisan storage:ls s3: ``` ```bash @@ -69,6 +73,10 @@ d 0 2019-08-21 11:19:46 public ```bash $ php artisan storage:ls -d s3 my-folder/sub-folder + +// or separate the disk and directory with a colon + +$ php artisan storage:ls s3:my-folder/sub-folder ``` ## List files and directories recursively diff --git a/composer.json b/composer.json index fdcf5c4..bc7030c 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "minimum-stability": "dev", "require": { - "illuminate/support": "~5.6|^6.0", + "illuminate/support": "~5.6|^6.0|^7.0", "php": "^7.0" }, "require-dev": { diff --git a/src/Console/Commands/ListStorage.php b/src/Console/Commands/ListStorage.php index 5c268cd..002c287 100644 --- a/src/Console/Commands/ListStorage.php +++ b/src/Console/Commands/ListStorage.php @@ -45,9 +45,22 @@ public function handle() return 1; } + $selectedDir = $this->argument('directory') ?? '/'; + $selectedDisk = $this->option('disk') ?? ''; $defaultDisk = config('filesystems.default'); + if ($selectedDisk === '' && strpos($selectedDir, ':') !== false) { + // User may be using the "disk:directory" format. + + [$diskSplit, $dirSplit] = explode(':', $selectedDir); + + if (array_key_exists($diskSplit, $disks)) { + $selectedDisk = $diskSplit; + $selectedDir = $dirSplit; + } + } + if ($selectedDisk !== '' && ! array_key_exists($selectedDisk, $disks)) { $this->error(sprintf('Selected disk "%s" does not exist', $selectedDisk)); $selectedDisk = ''; @@ -68,7 +81,6 @@ public function handle() return; } - $selectedDir = $this->argument('directory') ?? '/'; $recursive = $this->option('recursive'); $longFormat = $this->option('long');