Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Fix private methods.
Browse files Browse the repository at this point in the history
We stupidly can't use the exec() tool, for example *facepalm*
  • Loading branch information
aubreypwd committed Jan 16, 2023
1 parent 3a7b6e1 commit 4543c62
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ protected function has_command( string $command ) : bool {
* @param bool $force Force the run, even if we can't determine the command exists.
* @return array Data about the run.
*/
private function exec( string $command, $quiet = false, $force = false, ) : array {
protected function exec( string $command, $quiet = false, $force = false, ) : array {

if ( ! $force && ! $this->has_command( strtok( $command, ' ' ) ) ) {

Expand All @@ -161,31 +161,6 @@ private function exec( string $command, $quiet = false, $force = false, ) : arra
];
}

/**
* Run a command in a directory.
*
* You will have to use exec_* tools here to extrapolate data.
*
* @since 1.0.0
*
* @param string $command The command.
* @param string $directory The directory.
* @param bool $quietly Supress output.
* @return array Result data from aubreypwd\PHP_CLI\CLI::exec().
*/
protected function rid( string $command, string $directory, $quietly = false ) : string|array {

if ( ! file_exists( $directory ) ) {
throw new \Exception( "{$directory} doesn't exist." );
}

if ( empty( $command ) ) {
throw new \Exception( '$command is empty.' );
}

return $this->exec( "( cd '{$directory}' && {$command} )", $quietly, true );
}

/**
* Get the output of aubreypwd\PHP_CLI\CLI::exec().
*
Expand Down Expand Up @@ -237,10 +212,35 @@ protected function exec_get_status( array $exec ) : bool {
* @param array $exec Result of aubreypwd\PHP_CLI\CLI::exec().
* @return string
*/
private function exec_last_line( array $exec ) : string {
protected function exec_last_line( array $exec ) : string {
return isset( $exec['last_line'] ) ? trim( $exec['last_line'] ) : '';
}

/**
* Run a command in a directory.
*
* You will have to use exec_* tools here to extrapolate data.
*
* @since 1.0.0
*
* @param string $command The command.
* @param string $directory The directory.
* @param bool $quietly Supress output.
* @return array Result data from aubreypwd\PHP_CLI\CLI::exec().
*/
protected function rid( string $command, string $directory, $quietly = false ) : string|array {

if ( ! file_exists( $directory ) ) {
throw new \Exception( "{$directory} doesn't exist." );
}

if ( empty( $command ) ) {
throw new \Exception( '$command is empty.' );
}

return $this->exec( "( cd '{$directory}' && {$command} )", $quietly, true );
}

/**
* Explain/Register an argument.
*
Expand Down

0 comments on commit 4543c62

Please sign in to comment.