File tree 1 file changed +18
-1
lines changed
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
37
37
case 'File ' :
38
38
$ this ->outputToFile ();
39
39
break ;
40
+ case 'Clipboard ' :
41
+ $ this ->outputToClipboard ();
42
+ break ;
40
43
case 'Console ' :
41
44
$ this ->outputToConsole ();
42
45
break ;
@@ -156,7 +159,7 @@ protected function promptForMissingArgumentsUsing(): array
156
159
return [
157
160
'output ' => fn () => select (
158
161
'Where would you like to output the debug information? ' ,
159
- ['File ' , 'Console ' ],
162
+ ['File ' , 'Clipboard ' , ' Console ' ],
160
163
'File '
161
164
),
162
165
];
@@ -174,4 +177,18 @@ private function outputToConsole(): void
174
177
print_r ($ this ->debugInfo ->toArray (), true )
175
178
);
176
179
}
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
+ }
177
194
}
You can’t perform that action at this time.
0 commit comments