Skip to content

Commit acfde8a

Browse files
committed
implement possiblity to add raw commands
1 parent df0e8ae commit acfde8a

File tree

5 files changed

+43
-16
lines changed

5 files changed

+43
-16
lines changed

.github/workflows/main.yml

-12
This file was deleted.

.travis.yml

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ php:
44
- "7.2"
55
- "7.3"
66
- "7.4"
7+
- "nightly"
8+
9+
allow_failures:
10+
- "nightly"
711

812
cache:
913
directories:

docker-compose.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,18 @@ services:
77
- ./:/app
88
- ~/.ssh:/home/application/.ssh
99
- ~/.gitconfig:/home/application/.gitconfig
10-
- ~/.composer/cache:/home/application/.composer/cache
1110
environment:
1211
- XDEBUG_REMOTE_HOST=${XDEBUG_REMOTE_HOST:-}
1312
- XDEBUG_REMOTE_PORT=${XDEBUG_REMOTE_PORT:-9000}
1413
- php.xdebug.idekey=${XDEBUG_IDEKEY:-PHPSTORM}
1514
- php.xdebug.remote_log=${XDEBUG_REMOTE_LOG:-/tmp/xdebug.log}
1615
- PHP_DEBUGGER=${PHP_DEBUGGER:-none}
1716
working_dir: /app
17+
18+
php8:
19+
image: chrisb9/php8-nginx-xdebug
20+
volumes:
21+
- ./:/app
22+
- ~/.ssh:/home/application/.ssh
23+
- ~/.gitconfig:/home/application/.gitconfig
24+
working_dir: /app

src/ShellBuilder.php

+17-3
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,27 @@ public function removeVariable(string $variable): self
9999
}
100100

101101
/**
102-
* @param string|ShellInterface $command
102+
* @param string|ShellInterface ...$commands
103+
* @return $this
104+
* @throws ShellBuilderException
105+
*/
106+
public function add(...$commands): self
107+
{
108+
foreach ($commands as $command) {
109+
$this->addSingle($command);
110+
}
111+
return $this;
112+
}
113+
114+
/**
115+
* @param $command
116+
* @param bool $raw
103117
* @return $this
104118
* @throws ShellBuilderException
105119
*/
106-
public function add($command): self
120+
public function addSingle($command, bool $raw = false): self
107121
{
108-
$command = $this->parseCommand($command, true);
122+
$command = $raw ? $command : $this->parseCommand($command, true);
109123
if (empty($this->commandList)) {
110124
$this->commandList[] = $command;
111125
return $this;

tests/ShellBuilderTest.php

+14
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,20 @@ public function testBuilderConceptWithShortcut(): void
6363
$this->assertEquals($result, (string)$builder);
6464
}
6565

66+
public function testBuilderAddMany(): void
67+
{
68+
$builder = new ShellBuilder();
69+
$builder->add('a', 'b', 'c', 'd');
70+
$this->assertEquals('a ; b ; c ; d', (string)$builder);
71+
}
72+
73+
public function testBuilderAddRawCommand(): void
74+
{
75+
$builder = new ShellBuilder();
76+
$builder->addSingle('echo --colorize "hello world"', true);
77+
$this->assertEquals('echo --colorize "hello world"', (string)$builder);
78+
}
79+
6680
public function testCommandListDelimiter(): void
6781
{
6882
$result = (string)(new ShellBuilder())->add('a')->add('b')->add('c');

0 commit comments

Comments
 (0)