-
Notifications
You must be signed in to change notification settings - Fork 328
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
CLI stuck on prompt when running in non-interactive mode #142
Comments
After a quick look it seems like an issue with Vorpal. There was an issue with PR logged for it in the past (dthree/vorpal#166) but apparently there were some side-effects which is why it isn't available in the current build of Vorpal. Let's have a closer look and see if we can find a way to deal with this issue in the CLI. |
I've got a workaround for the issue in Vorpal. The only side effect is an extra empty line printed before and after the command output, but they seem harmless and acceptable trade-off to be able to correctly display prompts in the non-interactive mode in the CLI. I would appreciate it, if you could have a look at the fix guys, give it a test and tell me if I missed anything and if it would be acceptable to merge in the CLI. See the fix in my fork https://github.com/waldekmastykarz/office365-cli/tree/fix-noninteractiveprompt. |
Hey @waldekmastykarz, Tested on Windows and works as expected. Attached are Windows screens: I possess poor UI skills, but I personally do not care if it would print more empty lines. After all, one cmd/bash screen is ugly by design and this would not make big difference :). I would not pay attention if you did not mention it here. |
Thanks for checking @VelinGeorgiev. The result is similar (if not the same) as on macOS |
I've done some additional testing and it seems like the additional empty lines lead to errors when trying to process the JSON output. I tried using both jq in sh and ConvertFrom-Json in PowerShell. While the errors are slightly different, you do get an error which is specifically related to trailing empty line. We can't merge this fix in its current state as it would block users from building scripts using the CLI. It seems like Vorpal is adding more than just an empty line to the output. Here are the chars I'm seeing:
And it's exactly these first characters that trip parsing JSON. We could of course remove them using grep or something similar but it would unnecessarily complicate using the CLI. |
I have a working solution based on a fix applied to a forked Vorpal repo which you can see at https://github.com/waldekmastykarz/office365-cli/tree/fix-noninteractiveprompt-vorpal (notice the vorpal dep in package.json pointing to my forked repo with the fix). Ideally, we'd reference Vorpal from npm, but given the fix for our issue has been waiting for almost a year, I suspect chances are remote we will see it merged in the main repo any time soon. If it does happen, we can always flip back to the main repo. What do you think @andrewconnell @VelinGeorgiev? |
Agree @waldekmastykarz, this should be the way to go. I will have a look at that within the next few days. |
Rather than looking at the fork, have a look at the PR @VelinGeorgiev. I'm also planning to merge all PRs in a couple of days so we can give them a try in a beta version. |
@waldekmastykarz, this was in my todo list. I tested it and it works as expected in non-interactive mode with both |
Sweet! Thank you for another pair of eyes and confirming it's working as expected! |
When executing a command that yields a prompt, such as
spo app retract
, when executed in non-interactive mode, the CLI doesn't render the prompt in the shell. Instead it hangs. If the prompt is suppressed using the--confirm
option, the command works as expected. Verify if this is a limitation in Vorpal or a bug in the CLI implementation.The text was updated successfully, but these errors were encountered: