OpenAPITools / OpenAPITools/openapi-generator-cli

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

Abierto
#671 0 comentarios 0 reacciones 1 asignado Ver en GitHub

@kay-schecker ya está trabajando en esto.

Desde el 29/11/2022.

bug
Lenguaje dominante
TypeScript
Estrellas
2k
Forks
208
Merge medio
7 h 12 min
PR fusionados (30 d)
6

Descripción

🐛 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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.