I am trying to access command line form python code. here is two example where I got stuck. In this code, there is a question and 3 or 4 options to select as answer. How can I select any of these answer using python code. In real case If I am using it from command line I have to use up and down arrow
↑ ↓ key or right and left arrow < > key then enter key to select any one of the options.
*example:1>*
? How would you like to use ESLint? …
To check syntax only
▸ To check syntax and find problems
To check syntax, find problems, and enforce code style
*example:2>*
✔ How would you like to use ESLint? · problems
? What type of modules does your project use? …
▸ JavaScript modules (import/export)
CommonJS (require/exports)
None of these
Normally, I have to answer it by selecting answer from list and pressing enter from terminal, is there any possibility to answer these questions by using python code?
Here I am describing my use case.
I am trying to create automate ESLint vulnerability check for TypeScript files using python.
I am able to run ESLint --init to initialise ESLint in my project. While initializing ESLint --init is asking some questions to specify the type of project. Some of the questions are following:
*example:1>*
? How would you like to use ESLint? …
To check syntax only
▸ To check syntax and find problems
To check syntax, find problems, and enforce code style
*example:2>*
✔ How would you like to use ESLint? · problems
? What type of modules does your project use? …
▸ JavaScript modules (import/export)
CommonJS (require/exports)
None of these
Normally, I have to answer it by selecting answer from list and pressing enter from terminal, is there any possibility to answer these questions by using python code?
following code was used to run eslint --init from python code:
def eslint_init():
if pathlib.Path('.eslintrc.js').exists():
print('already initialized')
else:
os.system('eslint --init')