diff --git a/src/StaticPHP/Command/Dev/IsInstalledCommand.php b/src/StaticPHP/Command/Dev/IsInstalledCommand.php new file mode 100644 index 00000000..a3f69321 --- /dev/null +++ b/src/StaticPHP/Command/Dev/IsInstalledCommand.php @@ -0,0 +1,34 @@ +no_motd = true; + $this->addArgument('package', InputArgument::REQUIRED, 'The package name to check installation status'); + } + + public function handle(): int + { + $installer = new PackageInstaller(); + $package = $this->input->getArgument('package'); + $installer->addInstallPackage($package); + $installed = $installer->isPackageInstalled($package); + if ($installed) { + $this->output->writeln("Package [{$package}] is installed correctly."); + return static::SUCCESS; + } + $this->output->writeln("Package [{$package}] is not installed."); + return static::FAILURE; + } +} diff --git a/src/StaticPHP/Command/Dev/ShellCommand.php b/src/StaticPHP/Command/Dev/ShellCommand.php new file mode 100644 index 00000000..560cc7fe --- /dev/null +++ b/src/StaticPHP/Command/Dev/ShellCommand.php @@ -0,0 +1,33 @@ +output->writeln("Entering interactive shell. Type 'exit' to leave."); + + if (SystemTarget::isUnix()) { + passthru('PS1=\'[StaticPHP] > \' /bin/bash', $code); + return $code; + } + if (SystemTarget::getTargetOS() === 'Windows') { + passthru('cmd.exe', $code); + return $code; + } + $this->output->writeln('Unsupported OS for shell command.'); + return static::FAILURE; + } +} diff --git a/src/StaticPHP/ConsoleApplication.php b/src/StaticPHP/ConsoleApplication.php index 1f63190b..0484c111 100644 --- a/src/StaticPHP/ConsoleApplication.php +++ b/src/StaticPHP/ConsoleApplication.php @@ -6,6 +6,8 @@ namespace StaticPHP; use StaticPHP\Command\BuildLibsCommand; use StaticPHP\Command\BuildTargetCommand; +use StaticPHP\Command\Dev\IsInstalledCommand; +use StaticPHP\Command\Dev\ShellCommand; use StaticPHP\Command\DoctorCommand; use StaticPHP\Command\DownloadCommand; use StaticPHP\Command\ExtractCommand; @@ -47,6 +49,10 @@ class ConsoleApplication extends Application new BuildLibsCommand(), new ExtractCommand(), new SPCConfigCommand(), + + // dev commands + new ShellCommand(), + new IsInstalledCommand(), ]); // add additional commands from registries