9
9
use Php \Pie \ComposerIntegration \PieInstalledJsonMetadataKeys ;
10
10
use Php \Pie \File \BinaryFile ;
11
11
use Php \Pie \File \BinaryFileFailedVerification ;
12
+ use Php \Pie \Platform as PiePlatform ;
12
13
use Php \Pie \Platform \InstalledPiePackages ;
13
14
use Php \Pie \Platform \OperatingSystem ;
14
15
use Psr \Container \ContainerInterface ;
15
16
use Symfony \Component \Console \Attribute \AsCommand ;
16
17
use Symfony \Component \Console \Command \Command ;
17
18
use Symfony \Component \Console \Input \InputInterface ;
19
+ use Symfony \Component \Console \Input \InputOption ;
18
20
use Symfony \Component \Console \Output \NullOutput ;
19
21
use Symfony \Component \Console \Output \OutputInterface ;
20
22
33
35
)]
34
36
final class ShowCommand extends Command
35
37
{
38
+ private const OPTION_ALL = 'all ' ;
39
+
36
40
public function __construct (
37
41
private readonly InstalledPiePackages $ installedPiePackages ,
38
42
private readonly ContainerInterface $ container ,
@@ -45,12 +49,33 @@ public function configure(): void
45
49
parent ::configure ();
46
50
47
51
CommandHelper::configurePhpConfigOptions ($ this );
52
+
53
+ $ this ->addOption (
54
+ self ::OPTION_ALL ,
55
+ null ,
56
+ InputOption::VALUE_NONE ,
57
+ 'Show all extensions for the target PHP installation, even those PIE does not manage. ' ,
58
+ );
48
59
}
49
60
50
61
public function execute (InputInterface $ input , OutputInterface $ output ): int
51
62
{
63
+ $ showAll = $ input ->hasOption (self ::OPTION_ALL ) && $ input ->getOption (self ::OPTION_ALL );
52
64
$ targetPlatform = CommandHelper::determineTargetPlatformFromInputs ($ input , $ output );
53
65
66
+ if ($ output ->getVerbosity () < OutputInterface::VERBOSITY_VERBOSE ) {
67
+ $ output ->writeln (
68
+ sprintf (
69
+ '<info>Using pie.json:</info> %s ' ,
70
+ PiePlatform::getPieJsonFilename ($ targetPlatform ),
71
+ ),
72
+ );
73
+ }
74
+
75
+ if (! $ showAll ) {
76
+ $ output ->writeln ('Tip: to include extensions in this list that PIE does not manage, use the --all flag. ' );
77
+ }
78
+
54
79
$ composer = PieComposerFactory::createPieComposer (
55
80
$ this ->container ,
56
81
PieComposerRequest::noOperation (
@@ -64,12 +89,17 @@ public function execute(InputInterface $input, OutputInterface $output): int
64
89
$ extensionPath = $ targetPlatform ->phpBinaryPath ->extensionPath ();
65
90
$ extensionEnding = $ targetPlatform ->operatingSystem === OperatingSystem::Windows ? '.dll ' : '.so ' ;
66
91
67
- $ output ->writeln ("\n" . '<info>Loaded extensions:</info> ' );
92
+ $ output ->writeln (sprintf (
93
+ "\n" . '<options=bold,underscore>%s:</> ' ,
94
+ $ showAll ? 'All loaded extensions ' : 'Loaded PIE extensions ' ,
95
+ ));
68
96
array_walk (
69
97
$ phpEnabledExtensions ,
70
- static function (string $ version , string $ phpExtensionName ) use ($ output , $ piePackages , $ extensionPath , $ extensionEnding ): void {
98
+ static function (string $ version , string $ phpExtensionName ) use ($ showAll , $ output , $ piePackages , $ extensionPath , $ extensionEnding ): void {
71
99
if (! array_key_exists ($ phpExtensionName , $ piePackages )) {
72
- $ output ->writeln (sprintf (' <comment>%s:%s</comment> ' , $ phpExtensionName , $ version ));
100
+ if ($ showAll ) {
101
+ $ output ->writeln (sprintf (' <comment>%s:%s</comment> ' , $ phpExtensionName , $ version ));
102
+ }
73
103
74
104
return ;
75
105
}
0 commit comments