Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(consoleapp) Add /help command #284

Merged
merged 1 commit into from
Feb 19, 2022
Merged

Conversation

perlun
Copy link
Collaborator

@perlun perlun commented Feb 19, 2022

Closes #212.

@perlun perlun added enhancement New feature or request repl labels Feb 19, 2022
@perlun perlun added this to the 0.1.0 milestone Feb 19, 2022
standardOutputHandler($"Perlang Interactive REPL Console ({CommonConstants.GetFullVersion()}, built from git commit {CommonConstants.GitCommit})");
standardOutputHandler($"Perlang Interactive REPL Console (\x1B[1m{CommonConstants.GetFullVersion()}\x1B[0m, built from git commit {CommonConstants.GitCommit})");
standardOutputHandler("Type \x1B[36;1m/help\x1B[0m for more information or \x1B[36;1m/quit\x1B[0m to quit the program.");
standardOutputHandler(String.Empty);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The careful reader will notice that this makes quite heavy use of ANSI colouring sequences. This should even work on Windows nowadays, as of Windows 10 version 1909 (released in November 2019). I haven't verified it, but will test it at some point after merging this.

The REPL is always expected to be executed in "interactive" mode, but we should probably try to auto-detect the support for colour at some point. Or at the very least, add a --[no-]color option to be able to turn it on or off.

(Side note, but I know I might seem completely inconsistent with the "color" vs "colour" usage above. but I'm not sure I really am. I think that --color makes more sense as a command line option, since more people are likely to expect the Americanized spelling of this word. At the same time, I think I learned the British spellings in school (in Sweden where I grew up), and I kind of like it better for some odd reason. It feels more colourful or something... 😏)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... apparently not, after all (?). It doesn't look very pretty at all. We probably need to detect Windows and disable colors for now.

image

@@ -487,6 +517,7 @@ public string[] GetSuggestions(string text, int index)
{
var matchingKeywords = Scanner.ReservedKeywords
.Where(keyword => keyword.Key.StartsWith(text))
.Where(keyword => keyword.Value != TokenType.RESERVED_WORD)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Drive-by-fix: the reserved words doesn't make any sense to include in the GetSuggestions reuslt, since they are just "reserved for future use" in that sense.)

@perlun perlun merged commit f84b8da into master Feb 19, 2022
@perlun perlun deleted the feature/add-help-command-to-repl branch February 19, 2022 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request repl
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add /help command in REPL
1 participant