-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Command Line: Add support for command termination chars #3344
Command Line: Add support for command termination chars #3344
Conversation
Adds attribute line-termination-str
I'm honestly not a fan of this for multiple reasons. Firstly, it's brittle. The termination string completely disregards the actual syntax of the command language. This might be okay in the MySQL use-case you presented, but many other languages with a shell-like repl count brackets instead of relying on a statement terminator (in this case, a Side note: While the argument of disregarding syntax also somewhat applied to #3326, most shell-like languages are compatible with a simple Secondly, it changes the way line are categorized fundamentally. Prior to #3326, each line was their own; a line was either output or a command. #3326 changed that by adding the ability to merge adjacent command lines into one command. This change was conceptually built on top of how Command line categorized lines before. However, this PR work fundamentally different. With a termination string, we have to assume that all command lines are one block and then we split up that block using the terminator. So now we have 2 principals that work against each other: We have a bottom-up approach that tries to merge adjacent commands and a top-down approach that tries to split commands. This was my wordy explanation as to why I think that A simpler approach might be to add something like a |
@RunDevelopment thanks for looking at the PR. I hadn't appreciated that there are repls that parse the braces/brackets to determine continuation (is seems Scala is another example of this). In light of this I agree the approach of this PR is flawed. The if logic did get a bit complex, partly because I was trying to let it support both continuation and termination at the same time (no doubt somebody would want that at some point) rather than it being one mode or the other with one attribute trumping the other. Are you proposing removing <pre class="command-line" data-filter-output="(out)" data-filter-continuation="(con)" >
<code class="language-bash">export MY_VAR=123
echo "hello"
(out)hello
echo one \
(con)two \
(con)three
(out)one two three
(out)
echo "goodbye"
(out)goodbye</code>
</pre> ...OR having both I can see how using a continuation prefix gives total control to the content author and means Prism doesn't have to cater for all the different ways languages handle continuation. |
Yes, that one. I think |
Having both attrs works for me. Are you happy with |
Yes, sounds good. |
@RunDevelopment Please see the revised code and docs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! I really like the changes you made to the docs.
Just 2 minor things:
Thank you for contributing @at055612! |
Adds attribute
line-termination-str
to support multi-line commands in CLIs that use command termination chars instead of line continuation chars, e.g. SQL.Follows on from the merged PR #3326