Skip to content

Commit

Permalink
Merge branch 'master' of github.com:dalailomo/ace
Browse files Browse the repository at this point in the history
  • Loading branch information
dalailomo committed Dec 3, 2017
2 parents 1343199 + df3cdcb commit 1c173c5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
20 changes: 20 additions & 0 deletions src/Helper/Env.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace DalaiLomo\ACE\Helper;

class Env
{
public static function getPager()
{
$envPager = trim(shell_exec('echo $PAGER'));

return false === empty($envPager) ? $envPager : 'less';
}

public static function getEditor()
{
$envEditor = trim(shell_exec('echo $EDITOR'));

return false === empty($envEditor) ? $envEditor : 'nano';
}
}
3 changes: 2 additions & 1 deletion src/Setup/Section/EditConfigurationFileSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace DalaiLomo\ACE\Setup\Section;

use DalaiLomo\ACE\Helper\Env;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;

Expand All @@ -14,7 +15,7 @@ public function getSectionName()

public function doAction()
{
$process = new Process('vim ' . $this->config->getConfigFilePath());
$process = new Process(Env::getEditor() . ' ' . $this->config->getConfigFilePath());

try {
$process->setTty(true);
Expand Down
3 changes: 2 additions & 1 deletion src/Setup/Section/ListCommandGroupsSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use DalaiLomo\ACE\Helper\CommandOutputHelper;
use RomaricDrigon\MetaYaml\Exception\NodeValidatorException;
use DalaiLomo\ACE\Helper\Env;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;

Expand Down Expand Up @@ -31,7 +32,7 @@ public function doAction()
}

file_put_contents(self::TMP_FILE, $this->config->getSummary());
$process = new Process('less ' . self::TMP_FILE);
$process = new Process(Env::getPager() . ' ' . self::TMP_FILE);

try {
$process->setTty(true);
Expand Down
3 changes: 2 additions & 1 deletion src/Setup/Section/LogViewerSection/LogFileSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace DalaiLomo\ACE\Setup\Section\LogViewerSection;

use DalaiLomo\ACE\Helper\CommandOutputHelper;
use DalaiLomo\ACE\Helper\Env;
use DalaiLomo\ACE\Log\LogDecorator;
use DalaiLomo\ACE\Setup\Section\AbstractSection;
use Symfony\Component\Process\Exception\ProcessFailedException;
Expand Down Expand Up @@ -31,7 +32,7 @@ public function getSectionName()
public function doAction()
{
file_put_contents(self::TMP_FILE, $this->logDecorator->getStreamsOutput());
$process = new Process('less ' . self::TMP_FILE);
$process = new Process(Env::getPager() . ' ' . self::TMP_FILE);

try {
$process->setTty(true);
Expand Down

0 comments on commit 1c173c5

Please sign in to comment.