Nothing Special   »   [go: up one dir, main page]

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

Add configurable prompt #115

Merged
merged 2 commits into from
Oct 28, 2018
Merged

Add configurable prompt #115

merged 2 commits into from
Oct 28, 2018

Conversation

0verbyte
Copy link
Collaborator

First pass at allowing the repl prompt to be configured using a template string. The prompt configuration is set in the config file with the default template string ${ro}${w}> .

Currently the prompt supports the following:

  • ${ro} read-only mode. When Slacker is running in read-only mode this will be replaced with the contents of read_only_str config variable (default = (read-only) )
  • ${w} current workspace Slacker is using.

Additional entities could be added:

  • {u} for username, "username"
  • {uid} for user ID, "U8C3V3OQ"
  • {wid} for workspace ID, like "T9F3H7VLP"
  • {url} for workspace URL, like "https://workspace.slack.com/"

Other identifiers could easily be supported using this method, as discussed in #76.

This is a pretty trivial implementation as it doesn't have any lexical analysis, strictly a string replace. If we want to support more complex logic we'd have to subclass the Template class with our specific logic, or roll our own entirely.

Copy link
Owner
@netromdk netromdk left a comment

Choose a reason for hiding this comment

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

Very nice and it works great. Maybe it could mention somewhere in the code what is supported to write int he REPL prompt? It's not so easy to show in the config file but at least we could show it as a comment aboe DEFAULT_REPL_PROMPT in config.py? And possibly write a page on the wiki about it, too.

@0verbyte
Copy link
Collaborator Author

Added comments.

Yeah I was going to write a wiki entry for this once we agreed on the template identifiers and general implementation.

@netromdk netromdk merged commit 9d90fa5 into master Oct 28, 2018
@netromdk netromdk deleted the custom-repl-prompt branch October 28, 2018 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants