Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to disable property name logging in prompt #211

Open
m-Phoenix852 opened this issue Feb 23, 2021 · 7 comments
Open

Option to disable property name logging in prompt #211

m-Phoenix852 opened this issue Feb 23, 2021 · 7 comments

Comments

@m-Phoenix852
Copy link

How do I disable the property name, this explain https://stackoverflow.com/questions/41901072/node-js-prompt-how-to-disable-the-appearance-of-the-property-name#comment70985144_41901266

@caub
Copy link
Contributor

caub commented Feb 23, 2021

Can you post some code so I can reproduce your error?

@m-Phoenix852
Copy link
Author

Can you post some code so I can reproduce your error?

its not a error, I want to know how to disable the "prompt" string that is printed by the module with the prompt name whenever you prompt.get()

@caub
Copy link
Contributor

caub commented Feb 24, 2021

looking at the source, you can probably override it with prompt.message = ''; https://github.com/flatiron/prompt/blob/master/lib/prompt.js#L47

@m-Phoenix852
Copy link
Author

looking at the source, you can probably override it with prompt.message = ''; https://github.com/flatiron/prompt/blob/master/lib/prompt.js#L47

I tried that, doesn't work

@caub
Copy link
Contributor

caub commented Feb 25, 2021

can you show some code?

it works just fine for me, e.g.:

const prompt = require('prompt');
prompt.message = '';
const { code } = await prompt.get({
  properties: {
    code: {
      type: 'string',
      required: true,
    },
  }
});

outputs:

code: 

@m-Phoenix852
Copy link
Author

can you show some code?

it works just fine for me, e.g.:

const prompt = require('prompt');
prompt.message = '';
const { code } = await prompt.get({
  properties: {
    code: {
      type: 'string',
      required: true,
    },
  }
});

outputs:

code: 

Oh, how to remove the "code: " message

@caub
Copy link
Contributor

caub commented Feb 26, 2021

That doesn't sound like a good idea to remove any prefix, in terms of UX, but you could probably go with

const prompt=require('prompt');
prompt.message='';
prompt.delimiter='';
const data = await prompt.get(' '); // or prompt.get('\u200B'); because empty string seems to complain

just try out what works for you, I don't know much more about prompt than you, I just read the docs and the small source code to answer you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants