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

[BUG] tool assumes a tty and does not work correctly with a pipeline or stdout redirection #671

Open
DavidBiesack opened this issue Nov 29, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@DavidBiesack
Copy link

🐛 Bug Report:

Describe the bug

The tool appears to assume it is used in a TTY/console and does not work when redirecting stdout/stdout
Specifically:

openapi-generator-cli version-manager list

emits the following in a console:

? The following releases are available: (Use arrow keys)
  ☐  releasedAt  version      installed  versionTags                 
  -  ----------  -----------  ---------  ----------------------------
❯ ☐  2022-11-01  6.2.1        yes        6.2.1 stable latest          
  ☐  2022-09-24  6.2.0        no         6.2.0 stable                 
  ☐  2022-09-11  6.1.0        no         6.1.0 stable                 
  ☐  2022-07-03  6.0.1        no         6.0.1 stable                 
  ☐  2022-05-26  6.0.0        no         6.0.0 stable                 
  ☐  2022-04-04  6.0.0-beta   no         6.0.0-beta 6.0.0 beta beta   
  ☒  2022-01-31  5.4.0        yes        5.4.0 stable                 
  ☐  2021-12-21  5.3.1        no         5.3.1 stable                 
  ☐  2021-10-24  5.3.0        no         5.3.0 stable                 
  ☐  2021-08-16  5.2.1        no         5.2.1 stable                 
  ☐  2021-07-09  5.2.0        no         5.2.0 stable                 
  ☐  2021-05-07  5.1.1        no         5.1.1 stable                 
  ☐  2021-03-20  5.1.0        no         5.1.0 stable                 
  ☐  2021-02-06  5.0.1        no         5.0.1 stable                 
  ☐  2020-12-21  5.0.0        no         5.0.0 stable                 
  ☐  2020-11-20  5.0.0-beta3  no         5.0.0-beta3 5.0.0 beta3 beta 
  ☐  2020-09-04  5.0.0-beta2  no         5.0.0-beta2 5.0.0 beta2 beta 
  ☐  2020-06-29  5.0.0-beta   no         5.0.0-beta 5.0.0 beta beta   
  ☐  2020-05-06  4.3.1        no         4.3.1 stable                 
  ☐  2020-03-27  4.3.0        no         4.3.0 stable                 
  ☐  2020-01-31  4.2.3        no         4.2.3 stable                 
  ☐  2019-12-02  4.2.2        no         4.2.2 stable                 
  ☐  2019-11-15  4.2.1        no         4.2.1 stable                 
  ☐  2019-10-31  4.2.0        no         4.2.0 stable                 
  ☐  2019-10-04  4.1.3        no         4.1.3 stable                 
  ☐  2019-09-11  4.1.2        no         4.1.2 stable                 
  ☐  2019-08-26  4.1.1        no         4.1.1 stable                 
  ☐  2019-08-09  4.1.0        no         4.1.0 stable                 
  ☐  2019-07-09  4.0.3        no         4.0.3 stable                 
  ☐  2019-06-20  4.0.2        no         4.0.2 stable                 
  ☐  2019-05-31  4.0.1        no         4.0.1 stable                 
  ☐  2019-05-13  4.0.0        no         4.0.0 stable                 
  ☐  2019-04-04  4.0.0-beta3  no         4.0.0-beta3 4.0.0 beta3 beta 
  ☐  2019-01-31  4.0.0-beta2  no         4.0.0-beta2 4.0.0 beta2 beta 
  ☐  2018-12-31  4.0.0-beta   no         4.0.0-beta 4.0.0 beta beta   
  ☐  2018-11-30  3.3.4        no         3.3.4 stable                 
  ☐  2018-11-15  3.3.3        no         3.3.3 stable                 
  ☐  2018-10-31  3.3.2        no         3.3.2 stable                 
  ☐  2018-10-15  3.3.1        no         3.3.1 stable                 
  ☐  2018-10-01  3.3.0        no         3.3.0 stable                 
  ☐  2018-08-30  3.2.3        no         3.2.3 stable                 
  ☐  2018-08-22  3.2.2        no         3.2.2 stable                 
  ☐  2018-08-14  3.2.1        no         3.2.1 stable                 
  ☐  2018-08-06  3.2.0        no         3.2.0 stable                 
  ☐  2018-07-25  3.1.2        no         3.1.2 stable                 
  ☐  2018-07-18  3.1.1        no         3.1.1 stable                 
  ☐  2018-07-06  3.1.0        no         3.1.0 stable                 
  ☐  2018-06-27  3.0.3        no         3.0.3 stable                 
  ☐  2018-06-18  3.0.2        no         3.0.2 stable                 
  ☐  2018-06-11  3.0.1        no         3.0.1 stable                 
  ☐  2018-06-01  3.0.0        no         3.0.0 stable 
  -  ----------  -----------  ---------  ----------------------------

however, if you run this and redirect the output (or try to pipe it into another process, like grep),
the output is truncated and appears to be prompting a console to use arrow keys to prompt for selection

$ openapi-generator-cli version-manager list | grep yes

this hangs.

Redirect:

$ openapi-generator-cli version-manager list >| /tmp/list.txt

also hangs.

Pipe stdin from /dev/null :

$ openapi-generator-cli version-manager list < /dev/null >| /tmp/list.txt

shows the program is expecting input, and it also does not list all versions
before it detects an EOF on input and aborts prematurely:

$ cat /tmp/list.txt
? The following releases are available: (Use arrow keys)
  ☐  releasedAt  version      installed  versionTags                 
  -  ----------  -----------  ---------  ----------------------------
❯ ☐  2022-11-01  6.2.1        yes        6.2.1 stable latest          
  ☐  2022-09-24  6.2.0        no         6.2.0 stable                 
  ☐  2022-09-11  6.1.0        no         6.1.0 stable                 
  ☐  2022-07-03  6.0.1        no         6.0.1 stable                 
  ☐  2022-05-26  6.0.0        no         6.0.0 stable                 
(Move up and down to reveal more choices)

Expected behavior

When stdin or stdout is not a tty, the tool should simply run and list all versions, and not block on stdin.

Such interactive use should be a different command (select) and not just list -- a list command
should simply list the versions.

$ openapi-generator-cli version-manager list | grep yes
❯ ☐  2022-11-01  6.2.1        yes        6.2.1 stable latest          
  ☒  2022-01-31  5.4.0        yes        5.4.0 stable                 
$

Operation System (please complete the following information):

  • OS: macos
  • Version 12.6

Package System (please complete the following information):

  • Version 5.4
@DavidBiesack DavidBiesack added the bug Something isn't working label Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants