-
Notifications
You must be signed in to change notification settings - Fork 437
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
Switch from commander
to inquirer
#57
Comments
commander
to vorpal
commander
to inquirer
Example prompt: /**
* List prompt example
*/
var inquirer = require('inquirer');
var _ = require('lodash');
var fuzzy = require('fuzzy');
var Promise = require('promise');
inquirer.registerPrompt('autocomplete', require('./index'));
var states = [
'Alabama',
'Alaska',
'West Virginia',
'Wisconsin',
'Wyoming'
];
var foods = [
'Apple',
'Grapefruit',
];
function searchStates(answers, input) {
input = input || '';
return new Promise(function(resolve) {
var fuzzyResult = fuzzy.filter(input, states);
resolve(fuzzyResult.map(function(el) {
return el.original;
}));
});
}
function searchFood(answers, input) {
input = input || '';
return new Promise(function(resolve) {
var fuzzyResult = fuzzy.filter(input, foods);
resolve(fuzzyResult.map(function(el) {
return el.original;
}));
});
}
inquirer.prompt([{
type: 'autocomplete',
name: 'fruit',
// suggestOnly: true,
message: 'What is your favorite fruit?',
source: searchFood,
pageSize: 4,
validate: function(val) {
return val
? true
: 'Type something!';
}
}, {
type: 'autocomplete',
name: 'state',
message: 'Select a state to travel from',
source: searchStates
}]).then(function(answers) {
console.log(JSON.stringify(answers, null, 2));
}); |
So I've look at this for a bit today. There seems to not be an ideal solution that fits for clasp. The issues are multifold.
Command Prompt OptionsInquirer: Too basic. Can't take specific commands, treats everything as global. Here's a good tutorial of combining commander and inquirer: https://scotch.io/tutorials/build-an-interactive-command-line-application-with-nodejs CommandsI think # Commander
clasp # If there's no clasp project, displays help. If there's a clasp project, watch.
clasp login
clasp logout
clasp pull
clasp push [--watch]
clasp open
clasp deployments
clasp versions
clasp list
clasp logs [--json] [--open]
# Inquirer enhancement (leave off the arg and it'll prompt you)
clasp create [scriptTitle] [scriptParentId] – These can be prompted by the user
clasp clone <scriptId> – clasp list the scriptId.
clasp deploy [version] [description] - clasp deploy would prompt the user
clasp redeploy ... - clasp redeploy would prompt the user
clasp version - clasp version would prompt the user SummaryI think a combination of |
Inquirer is complete for |
I am going to try this! |
Do we need to migrate other functions? |
@takanakahiko It would be nice if The 2.0 interface is described here: |
I may have to revisit this and use the up and rising CLI framework |
Give autocompletion for `clasp commands.
clasp <tab>
Vorpal seems to be based on
commander
and provides these features.The text was updated successfully, but these errors were encountered: