Skip to content

Commit

Permalink
updat esome for cmd run
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Apr 27, 2021
1 parent 58738ee commit 21a8163
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
12 changes: 11 additions & 1 deletion app/Common/CmdRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,14 @@ public function addByArray(array $config, string $key = ''): self
return $this;
}

/**
* run and print all output
*/
public function runAndPrint(): void
{
$this->run(true);
}

/**
* Run all added commands
*
Expand All @@ -329,7 +337,6 @@ public function addByArray(array $config, string $key = ''): self
public function run(bool $printOutput = false): self
{
$this->printOutput = $printOutput;

if ($command = $this->command) {
$this->innerExecute($command, $this->workDir);

Expand All @@ -347,6 +354,9 @@ public function run(bool $printOutput = false): self
return $this;
}

/**
* @param array $commands
*/
private function runCommands(array $commands): void
{
Color::println('Starting Handle', 'suc');
Expand Down
18 changes: 9 additions & 9 deletions app/Console/Controller/GitUseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function updateCommand(Input $input, Output $output): void
$runner = CmdRunner::new();
$runner->setDryRun($input->getBoolOpt('dry-run'));
$runner->add('git pull');
$runner->run(true);
$runner->runAndPrint();

$output->success('Complete');
}
Expand All @@ -159,7 +159,7 @@ public function pushCommand(Input $input, Output $output): void
$runner = CmdRunner::new();
$runner->setDryRun($input->getBoolOpt('dry-run'));
$runner->add('git push');
$runner->run(true);
$runner->runAndPrint();

$output->success('Complete');
}
Expand All @@ -175,7 +175,7 @@ public function statusCommand(Input $input, Output $output): void
'git status' // git status -s
];

CmdRunner::new()->batch($commands)->run(true);
CmdRunner::new()->batch($commands)->runAndPrint();
}

/**
Expand Down Expand Up @@ -284,7 +284,7 @@ public function batchPullCommand(): void
'git remote -v',
];

CmdRunner::new()->batch($commands)->run(true);
CmdRunner::new()->batch($commands)->runAndPrint();
}

/**
Expand Down Expand Up @@ -423,7 +423,7 @@ public function tagInfoCommand(Input $input, Output $output): void
"git show $tag",
];

CmdRunner::new()->batch($commands)->run(true);
CmdRunner::new()->batch($commands)->runAndPrint();
}

/**
Expand Down Expand Up @@ -494,7 +494,7 @@ public function tagNewCommand(Input $input, Output $output): void
$run->setDryRun($dryRun);
$run->addf('git tag -a %s -m "%s"', $tag, $msg);
$run->addf('git push origin %s', $tag);
$run->run(true);
$run->runAndPrint();

$output->success('Complete');
}
Expand Down Expand Up @@ -530,7 +530,7 @@ public function tagDeleteCommand(Input $input, Output $output): void
$run->addf('git push %s :refs/tags/%s', $remote, $tag);
}

$run->run(true);
$run->runAndPrint();

$output->success('Complete');
}
Expand Down Expand Up @@ -654,7 +654,7 @@ public function changelogCommand(Input $input, Output $output): void
CMD;

$runner = CmdRunner::new(trim($logCmd));
$runner->do(true);
$runner->runAndPrint();

$output->success('Complete');
return;
Expand All @@ -668,7 +668,7 @@ public function changelogCommand(Input $input, Output $output): void
CMD;

$runner = CmdRunner::new(trim($logCmd));
$runner->do(true);
$runner->runAndPrint();

$output->success('Complete');
}
Expand Down

0 comments on commit 21a8163

Please sign in to comment.