File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,9 @@ public function handle(): void
3737 case 'File ' :
3838 $ this ->outputToFile ();
3939 break ;
40+ case 'Clipboard ' :
41+ $ this ->outputToClipboard ();
42+ break ;
4043 case 'Console ' :
4144 $ this ->outputToConsole ();
4245 break ;
@@ -156,7 +159,7 @@ protected function promptForMissingArgumentsUsing(): array
156159 return [
157160 'output ' => fn () => select (
158161 'Where would you like to output the debug information? ' ,
159- ['File ' , 'Console ' ],
162+ ['File ' , 'Clipboard ' , ' Console ' ],
160163 'File '
161164 ),
162165 ];
@@ -174,4 +177,18 @@ private function outputToConsole(): void
174177 print_r ($ this ->debugInfo ->toArray (), true )
175178 );
176179 }
180+
181+ private function outputToClipboard (): void
182+ {
183+ $ json = json_encode ($ this ->debugInfo ->toArray (), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES );
184+
185+ // Copy json to clipboard
186+ if (PHP_OS_FAMILY === 'Windows ' ) {
187+ Process::run ('echo ' . escapeshellarg ($ json ) . ' | clip ' );
188+ } elseif (PHP_OS_FAMILY === 'Linux ' ) {
189+ Process::run ('echo ' . escapeshellarg ($ json ) . ' | xclip -selection clipboard ' );
190+ } else {
191+ Process::run ('echo ' . escapeshellarg ($ json ) . ' | pbcopy ' );
192+ }
193+ }
177194}
You can’t perform that action at this time.
0 commit comments