FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

I have a lot of help and don't want it to scroll off the screen. by hexmode · Pull Request #9 · splitbrain/php-cli · GitHub

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .php  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
52 changes: 44 additions & 8 deletions src/Options.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,26 @@ public function setHelp($help)
$this->setup['']['help'] = $help;
}

/**
* Sets the help text for the tool's commands
*
* @param string $help
*/
public function setCommandHelp($help)
{
$this->setup['']['commandhelp'] = $help;
}

/**
* Sets the help text for the tools commands itself
*
* @param boolean $compact
*/
public function setCompactHelp($compact=true)
{
$this->setup['']['compacthelp'] = $compact;
}

/**
* Register the names of arguments for help generation and number checking
*
Expand Down Expand Up @@ -334,6 +354,10 @@ public function help()
$text = '';

$hascommands = (count($this->setup) > 1);
$commandhelp = $this->setup[""]["commandhelp"]
?: 'This tool accepts a command as first parameter as outlined below:';
$compacthelp = $this->setup[""]["compacthelp"] ?: false;

foreach ($this->setup as $command => $config) {
$hasopts = (bool)$this->setup[$command]['opts'];
$hasargs = (bool)$this->setup[$command]['args'];
Expand All @@ -345,7 +369,9 @@ public function help()
$text .= ' ' . $this->bin;
$mv = 2;
} else {
$text .= "\n";
if (!$compacthelp) {
$text .= "\n";
}
$text .= $this->colors->wrap(' ' . $command, Colors::C_PURPLE);
$mv = 4;
}
Expand All @@ -366,21 +392,24 @@ public function help()
}
$text .= ' ' . $out;
}
$text .= "\n";
if (!$compacthelp) {
$text .= "\n";
}

// usage or command intro
if ($this->setup[$command]['help']) {
$text .= "\n";
$text .= $tf->format(
array($mv, '*'),
array('', $this->setup[$command]['help'] . "\n")
array('', $this->setup[$command]['help']
. ($compacthelp ? '' : "\n"))
);
}

// option description
if ($hasopts) {
if (!$command) {
$text .= "\n";
$text .= "\n";
$text .= $this->colors->wrap('OPTIONS:', Colors::C_BROWN);
}
$text .= "\n";
Expand All @@ -399,12 +428,15 @@ public function help()
$name .= ' <' . $opt['needsarg'] . '>';
}

if (!$compacthelp) {
$text .= "\n";
}

$text .= $tf->format(
array($mv, '30%', '*'),
array('', $name, $opt['help']),
array('', 'green', '')
);
$text .= "\n";
}
}

Expand All @@ -414,7 +446,9 @@ public function help()
$text .= "\n";
$text .= $this->colors->wrap('ARGUMENTS:', Colors::C_BROWN);
}
$text .= "\n";
if (!$compacthelp) {
$text .= "\n";
}
foreach ($this->setup[$command]['args'] as $arg) {
$name = '<' . $arg['name'] . '>';

Expand All @@ -433,9 +467,11 @@ public function help()
$text .= "\n";
$text .= $tf->format(
array($mv, '*'),
array('', 'This tool accepts a command as first parameter as outlined below:')
array('', $commandhelp)
);
$text .= "\n";
if (!$compacthelp) {
$text .= "\n";
}
}
}

Expand Down

Back | FazBrowse Home | New Git URL