Skip to content

Commit b48babd

Browse files
committed
Prettier REPL header and stuff.
1 parent ce794de commit b48babd

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

primi

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ $interpreter = new \Smuuf\Primi\Interpreter($context, __DIR__ . "/temp/");
2121

2222
// Determine the source. Act as REPL if no source was specified.
2323
if (empty($config['input'])) {
24-
echo header_string('REPL') . "\n";
24+
echo header_string('REPL');
2525
$repl = new \Smuuf\Primi\Repl($interpreter);
2626
$repl->start();
2727
die;
@@ -116,8 +116,5 @@ HELP;
116116

117117
function header_string(string $env = null) {
118118
$env = $env ? "($env)" : null;
119-
return "Primi language {$env}, Copyright (c) Premysl Karbula\n" .
120-
"Type 'exit' to exit.\n" .
121-
"Type '?' to print local variables or '??' to print all variables.\n" .
122-
"The latest result is stored in '_' variable.\n";
119+
return "Primi language {$env}, Copyright (c) Premysl Karbula\n";
123120
}

src/Repl.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public function __construct(
3636
$rawOutput = false
3737
) {
3838

39+
self::printHelp();
40+
3941
$this->interpreter = $interpreter;
4042
$this->rawOutput = $rawOutput;
4143
$this->driver = $driver ?: new \Smuuf\Primi\Readline;
@@ -44,6 +46,17 @@ public function __construct(
4446

4547
}
4648

49+
protected static function printHelp() {
50+
51+
echo Colors::get("\n".
52+
"{green}Use '{_}exit{green}' to exit.\n" .
53+
"Use '{_}?{green}' to view local variables " .
54+
"or '{_}??{green}' to view all variables.\n" .
55+
"The latest result is stored in '{_}_{green}' variable.\n\n"
56+
);
57+
58+
}
59+
4760
public function start() {
4861

4962
// Allow saving history even on serious errors.

src/repl/Colors.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class Colors extends \Smuuf\Primi\StrictObject {
2525
'purple' => '0;35',
2626
'lightpurple' => '1;35',
2727
'brown' => '0;33',
28-
'yellow' => '1;33',
28+
'yellow' => '0;33',
29+
'lightyellow' => '1;33',
2930
'lightgray' => '0;37',
3031
'lightgrey' => '0;37',
3132
'white' => '1;37',

0 commit comments

Comments
 (0)