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

Add ability to dynamicaly skip a prompt #118

Merged
merged 6 commits into from Feb 5, 2016
Merged

Add ability to dynamicaly skip a prompt #118

merged 6 commits into from Feb 5, 2016

Conversation

fujifish
Copy link

It is sometimes useful to control whether to display a prompt to the user based on previous answers.
This PR adds a new ask method to a property that enables to skip the prompt based on custom logic.

E.g.:

  var schema = {
    properties: {
      proxy: {
        description: 'Proxy url',
      },
      proxyCredentials: {
        description: 'Proxy credentials',
        ask: function() {
          // only ask for proxy credentials if a proxy was set
          return prompt.history('proxy').value > 0;
        }
      }
    }
  };

I've also included two other minor enhancements:

  1. If prompt.message is set to an empty string then do not print the delimiter
  2. If a property is not valid and has a message defined, then do not print the generic "Invalid input for ..." message.

Great project by the way!

var prefix = prompt.message && prompt.message.length > 0 ? prompt.message + delim : '',
raw = prompt.colors
? [prefix, name.grey, delim.grey]
: [prefix, name, delim];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This functionality has been fixed in the created-before-this-but-only-recently-merged #61

@gangstead
Copy link
Member

Sorry this sat for so long, I've started helping on this project (yesterday). This looks really good, thanks for including updates to the docs too.

I've put some other changes in which makes this need an update. Do you think you could do a pull and fix the conflicts so I can accept this PR?

@fujifish
Copy link
Author

fujifish commented Feb 5, 2016

done both requests.

@gangstead gangstead merged commit 51dd957 into flatiron:master Feb 5, 2016
@gangstead
Copy link
Member

I fixed the test that was failing. It was looking for "Invalid Input" but now that extra line doesn't show up if schema.message is set.

@gangstead
Copy link
Member

Thanks!

@fujifish
Copy link
Author

fujifish commented Feb 7, 2016

Thanks. When is a release to NPM expected?

@gangstead
Copy link
Member

As son as i can get permission i will. Working on it with the admins #144

@jcrugzz
Copy link
Member

jcrugzz commented Feb 7, 2016

v0.3.0 is relased in npm

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

Successfully merging this pull request may close these issues.

None yet

3 participants