Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Application.php
  • Loading branch information
g105b committed Jun 14, 2019
2 parents 90d4e89 + d928e5e commit f83f193
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 79 deletions.
7 changes: 6 additions & 1 deletion src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@ public function __construct(
$this->arguments = $arguments;
$this->commands = $commands;

$script = null;
if($arguments) {
$script = $arguments->getScript();
}

$this->helpCommand = new HelpCommand(
$this->description,
$arguments->getScript(),
$script,
$this->commands
);
$this->versionCommand = new VersionCommand(
Expand Down
15 changes: 9 additions & 6 deletions src/Command/HelpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class HelpCommand extends Command {
*/
public function __construct(
string $applicationDescription,
string $scriptName,
string $scriptName = null,
array $applicationCommandList = []
) {
$this->applicationDescription = $applicationDescription;
Expand All @@ -28,10 +28,13 @@ public function __construct(
}

public function run(ArgumentValueList $arguments = null): void {
$command = (string)$arguments->get(
"command",
self::ALL_COMMANDS
);
$command = null;
if($arguments) {
$command = (string)$arguments->get(
"command",
self::ALL_COMMANDS
);
}

if($command === self::ALL_COMMANDS) {
$output = $this->getHelpForAllCommands();
Expand Down Expand Up @@ -113,7 +116,7 @@ protected function getHelpForAllCommands():string {
return $output;
}

protected function getHelpForCommand(string $commandName):string {
protected function getHelpForCommand(string $commandName = null):string {
$output = "";

$command = null;
Expand Down
6 changes: 3 additions & 3 deletions test/unit/Command/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,23 +235,23 @@ public function testGetUsageSingleRequiredNamedParameter() {
public function testGetUsageMultipleRequiredParameter() {
$command = new MultipleRequiredParameterCommand();
self::assertEquals(
"Usage: multiple-required-parameter-command id name --framework|-f rinky-dink --example",
"Usage: multiple-required-parameter-command id name --framework|-f FRAMEWORK --example",
$command->getUsage()
);
}

public function testGetUsageComboRequiredOptionalParameter() {
$command = new ComboRequiredOptionalParameterCommand();
self::assertEquals(
"Usage: combo-required-optional-parameter-command id [name] --type|-t TYPE_VALUE [--verbose|-v]",
"Usage: combo-required-optional-parameter-command id [name] --type|-t TYPE [--verbose|-v]",
$command->getUsage()
);
}

public function testGetUsageAllParameterTypes() {
$command = new AllParameterTypesCommand();
self::assertEquals(
"Usage: all-parameter-types-command id [name] --type|-t TYPE_VALUE [--log|-l LOG_PATH] [--verbose|-v]",
"Usage: all-parameter-types-command id [name] --type|-t TYPE [--log|-l LOG_PATH] [--verbose|-v]",
$command->getUsage()
);
}
Expand Down
67 changes: 0 additions & 67 deletions test/unit/Command/HelpCommandTest.php

This file was deleted.

1 change: 1 addition & 0 deletions test/unit/Helper/Command/AllParameterTypesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function getOptionalParameterList():array {
true,
"log",
"l",
"The path of your log file",
"LOG_PATH"
),
new Parameter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public function getRequiredParameterList():array {
new Parameter(
true,
"type",
"t"
"t",
"What type of thing you are using"
),
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getRequiredParameterList():array {
true,
"framework",
"f",
"rinky-dink"
"The name of your framework"
),
new Parameter(
false,
Expand Down

0 comments on commit f83f193

Please sign in to comment.