SamVerschueren / listr

Terminal task list

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to allow prompting for password?

kykungz opened this issue · comments

I used listr to execute commands with execa, which some of commands required sudo permission which asks for password.

However, it seems like the loading state of listr task is overriding my password prompts, giving no feedback to users to type in the password. Although I can still type in the password and press Enter, it is hard to determine that they are prompting for password.

Any solution?

seams no more maintainers here 😞

Could you make a case for me then I can work on it?

You can do something like this but if you change one thing in source code of project 😐

import { UpdateRenderer, render /** This is the change I was talking about */ } from 'listr-update-renderer'

/* Some state management to export to change the state */
export const RenderState = {
  pause: false
}

export class MyRenderer extends UpdateRenderer {

  _id;
  _tasks;
  _options;

  render() {
    if (this._id) {
       // Do not render if we are already rendering
       return;
    }

    this._id = setInterval(() => {
       if (RenderState.pause) {
          return
       }
       render(this._tasks, this._options);
    }, 100);
  }

}

then you can do something like this in your task

task: async (ctx, task) => {
  RenderState.pause = true;
  await cli.confirm('Are you sure?')
  RenderState.pause = false;
}

💥