From ffc2bcfc17933593ba1cec88f05ec09159594693 Mon Sep 17 00:00:00 2001 From: sagarnasit Date: Mon, 24 Dec 2018 18:54:45 +0530 Subject: [PATCH 1/3] Add -T flag to disable TTY allocation on use of --command --- src/Shell_Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Shell_Command.php b/src/Shell_Command.php index 4109277..5308452 100644 --- a/src/Shell_Command.php +++ b/src/Shell_Command.php @@ -76,7 +76,7 @@ public function __invoke( $args, $assoc_args ) { $shell = ( 'mailhog' === $service ) ? 'sh' : 'bash'; $command = \EE\Utils\get_flag_value( $assoc_args, 'command' ); if ( $command ) { - EE::exec( "docker-compose exec $user_string $service $shell -c \"$command\"", true, true ); + EE::exec( "docker-compose exec -T $user_string $service $shell -c \"$command\"", true, true ); } else { $this->run( "docker-compose exec $user_string $service $shell" ); } From db4dd0ef0eb0d1517b182aa825ccc7befc4530ce Mon Sep 17 00:00:00 2001 From: sagarnasit Date: Tue, 25 Dec 2018 11:47:11 +0530 Subject: [PATCH 2/3] Add --skip-tty flag to skip tty allocation --- src/Shell_Command.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Shell_Command.php b/src/Shell_Command.php index 5308452..33be795 100644 --- a/src/Shell_Command.php +++ b/src/Shell_Command.php @@ -35,6 +35,9 @@ class Shell_Command extends EE_Command { * [--command=] * : Command to non-interactively run in the shell. * + * [--skip-tty] + * : Skips tty allocation. + * * ## EXAMPLES * * # Open shell for site @@ -75,8 +78,14 @@ public function __invoke( $args, $assoc_args ) { $shell = ( 'mailhog' === $service ) ? 'sh' : 'bash'; $command = \EE\Utils\get_flag_value( $assoc_args, 'command' ); + + $tty = ''; + if ( \EE\Utils\get_flag_value( $assoc_args, 'skip-tty' ) ) { + $tty = '-T'; + } + if ( $command ) { - EE::exec( "docker-compose exec -T $user_string $service $shell -c \"$command\"", true, true ); + EE::exec( "docker-compose exec $tty $user_string $service $shell -c \"$command\"", true, true ); } else { $this->run( "docker-compose exec $user_string $service $shell" ); } From f028f87f51466918677c02ec1a3ec1cb830fb095 Mon Sep 17 00:00:00 2001 From: sagarnasit Date: Tue, 25 Dec 2018 12:01:27 +0530 Subject: [PATCH 3/3] Use ternary condition instead of if condition --- src/Shell_Command.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Shell_Command.php b/src/Shell_Command.php index 33be795..c2ec3ad 100644 --- a/src/Shell_Command.php +++ b/src/Shell_Command.php @@ -2,6 +2,7 @@ use EE\Model\Site; use function EE\Site\Utils\auto_site_name; +use function EE\Utils\get_flag_value; /** * Brings up a shell to run wp-cli, composer etc. @@ -79,10 +80,7 @@ public function __invoke( $args, $assoc_args ) { $shell = ( 'mailhog' === $service ) ? 'sh' : 'bash'; $command = \EE\Utils\get_flag_value( $assoc_args, 'command' ); - $tty = ''; - if ( \EE\Utils\get_flag_value( $assoc_args, 'skip-tty' ) ) { - $tty = '-T'; - } + $tty = get_flag_value( $assoc_args, 'skip-tty' ) ? '-T' : ''; if ( $command ) { EE::exec( "docker-compose exec $tty $user_string $service $shell -c \"$command\"", true, true );