Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

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

Ouverte
#671 0 commentaires 0 réactions 1 personne assignée Voir sur GitHub

@kay-schecker y travaille déjà.

Depuis le 29/11/2022.

Évaluation

Cette issue n'a pas encore été évaluée.

Description

bug

🐛 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
Langage dominant
TypeScript
Étoiles
2k
Forks
210
Merge moyen
7 h
PR mergées (30 j)
3

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la premiÚre contribution pour les étapes générales.

Par oĂč commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela Ă©vite que deux personnes fassent le mĂȘme travail.
  3. Forkez le dépÎt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de OpenAPITools/openapi-generator-cli

Toutes les issues de OpenAPITools/openapi-generator-cli

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.