-
Notifications
You must be signed in to change notification settings - Fork 31
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
Configuration for continuation prompt (like PS2 or PROMPT2 in some shells) #183
Comments
I have implemented the prototype. |
Sorry for the delayed comment. The reason why I chose I have used spanner-cli and experienced several times that the current prompt ( Do you have any good example we should keep using |
I'm not confident enough to say that prompt2 is harmful. e.g.
It seems psql has similar functionality(
|
Thank you for sharing the reference, but still I'm not sure if it's really useful or not. I checked this blog article about Prompt2 usage for Postgres, but I feel it's more complicated and hard to understand what that prompt means. Excerpt from the article:
Of course, it depends on the prompt the user sets, but instead of letting the user to choose the prompt, I want to provide the best option that's useful for most of the use cases. In that sense I still lean toward the option that removes the prompt at all. |
Maybe we can 1) change the default prompt2 as an empty string and 2) provide the command line option to allow users to change the prompt2. But I'm wondering how many users will use that command line option. |
I think the example of that article is not practical because multiline string literals are not popular in regular SQL queries. sqlite has similar functionality in continuation prompt.
|
After investigating, I think parser status in continuation prompt is common and useful feature in SQL interactive shells in ideal, but it is not low hanging fruits. I'm worried that removing the continuation prompt completely in default will confuse users because they won't know if they're still in the middle of typing. |
Currently, the statement separator (gsqlsep) only considers quotes and comments, so some change is required to show if they are inside parentheses. |
I have come to the following thought:
So I think spanner-cli needs a boolean flag to set the continuation prompt to whitespace.
|
Adding the option to disable the prompt2 is fine, but I still doubt that it can address the user's pain points when they want to copy/paste the multi-line queries. This is because there is less chance the (light) users will be aware of the existence of the option and they might keep using the default prompt. This is not an urgent task, so let's keep this discussion open and here the feedback from other users as well. |
I suspect that feedback on issues is biased towards only heavy users. I think we need to go back to why continuation prompts exist as a convention. I don't yet do deep research about retionale of PROMPT2, but I think this question is an example of the need for continuation prompts for novice users. Without a continuation prompt, a novice user would not aware that spanner-cli was continuing to read and wait for something.
I found that PostgreSQL ML contains a similar topic. |
MySQL document also have many sentence about the prompt. |
I understand it's not a good idea to remove the continuation prompt by default as it confuses users when the terminating semicolon is not entered. Given that removing the continuation prompt likely confuses users (even heavy users as well), I feel it's not also a good idea to provide the option to remove the continuation prompt. If there is a situation when a user wants to copy the multi-line query itself, it can be accomplished by looking back the query history ( |
I'm glad to agree abount the default continuation prompt.
I feel that
Currently, line edit history only get a single line of a past query.
It's afraid that it silently changes the meaning of a query. |
Yes, it's not strange to have that option, but the only concern I have is it likely becomes "yet another" option that might be used by only a few users in a limited situation, and we have to keep maintaining it. Of course we already have many optional options (10 options) in spanner-cli and I'm struggling to keep the balance for what we should add/shouldn't add to keep the tool simple.
I think it's not so serious because I don't think many people enter comments or multi-line literals in an interactive way. If it's really serious, we have to change even the current implementation with stopping showing the query history when multi-line query is used, but I haven't heard of such issue yet. |
One random idea to avoid adding a new option is making a new prompt variable in For example, when a user specify The downside is that it's not intuitive, but given that it might be used by only a few (heavy) users in a limited situation, that might be acceptable. It's just a random thought though. |
I think it may be a problem to keep
psql's
I think this is a related but independent problem to prompt2,
Current history implementation shows every unexecutable line flagment for multi-line queries. My thought:
|
It is a possible implementation. If the ini only option is acceptable, I think it is no reason to extend |
Random thought |
It's better than providing nothing, so +1 on this change as an initial implementation. |
My thoughts about the prompt alignment are
|
I assume that readability can be compromised when the Project ID: 30 characters If spanner-cli always right align continuation prompt to first prompt line, There are some options.
FYI: I can't found other implementation which support prompt configuration and default alignment. psql
sqlite
mysql
So, I am not sure whether your expectation is common sense to other users. |
Maybe "readability" was not good word. Let me rephrase it. spanner-cli is an interactive CLI, so I assume that users write multi-line query in real time. When user writes multi-line query from the first line to the second line, if the prompt is not aligned, the user has to move their eyes back and forth to check whole query. This process continues until the whole query is constructed. This is apparently not good for usability. I think the example in the last reply is the edge case and doesn't reflect the real use case. If it's difficult to write a multi-line query with prompt alignment due to short space, the same is true for the single-line query. So I guess that nobody use such a long project/instance/database names or long prompt. Anyway, instead of having a discussion around an edge case, let's focus on solving the core issue we have discussed - unable to copy/paste multi-line query. To solve that, what we have discussed are:
|
OK, we should talk about a concrete solution.
I think it is a possible solution for all personas. What do you think? |
I want to fork some problem to another issue.
I guess it is simply because |
I don't know if we've reached an agreement. My proposal
|
Sorry for the delayed response. As I commented at #183 (comment), I don't think we need to allow users to customize the prompt alignment. Also my proposal at that comment was providing So my updated suggestion is:
|
Since there seems to be no consensus on implementing I have no |
Sometimes, we want to reuse queries by copy-and-paste, but multi-line prompts make it harder.
It is harder to reuse than indentation like
Currently, the prompt string for continuous line is hard coded.
https://github.com/cloudspannerecosystem/spanner-cli/blob/v0.10.4/cli.go#L353
It would be nice to have configuration like
PROMPT2
in some shells or bool flag (--only-indent-multiline
?).The text was updated successfully, but these errors were encountered: