Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

cli.promt('my question'); is instantly moving on when the user presses any key #120

Open
jemilox opened this issue Aug 2, 2019 · 0 comments

Comments

@jemilox
Copy link

jemilox commented Aug 2, 2019

Using Oclif default hello world.

The command line moves on the instant that I press any key. It doesn't wait for me to finish typing my name and hit enter. Is there something I am missing here?

Screen Shot 2019-08-02 at 3 07 21 PM

import { Command, flags } from '@oclif/command';
import chalk from 'chalk';
import { meow } from '../flags';
import cli from 'cli-ux';

export default class Hello extends Command {
  static description = 'describe the command here';

  static flags = {
    help: flags.help({ char: 'h' }),
    // flag with a value (-n, --name=VALUE)
    name: flags.string({ char: 'n', description: 'name to print' }),
    // flag with no value (-f, --force)
    force: flags.boolean({ char: 'f' }),
    meow: meow,
  };

  static args = [{ name: 'file' }];

  async run() {
    const yourName = await cli.prompt('What is your name?');
    console.log(`your name is ${yourName}`);

    const { args, flags } = this.parse(Hello);

    if (flags.meow) console.log('MEOW');

    const name = flags.name || 'WORLD';

    this.log(chalk.bgCyan.bold(`\nHELLO ${name}!\n`));
  }
}
@jemilox jemilox changed the title cli.promt( cli.promt('my question'); is instantly moving on when the user presses any key Aug 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant