You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.4 KiB
87 lines
2.4 KiB
const inquirer = require('inquirer');
|
|
|
|
module.exports = {
|
|
isPushAll() {
|
|
return new Promise((resolve, reject) => {
|
|
inquirer.prompt([{
|
|
type: 'confirm', // 问题类型,包括input,number,confirm,list,rawlist,password
|
|
name: 'all',
|
|
message: '是否提交所有源', // 问题
|
|
default: true // 默认值
|
|
}]).then(async answers => {
|
|
if (answers.all) {
|
|
resolve(true);
|
|
} else {
|
|
resolve(false);
|
|
}
|
|
})
|
|
})
|
|
},
|
|
pushMsg() {
|
|
return new Promise((resolve, reject) => {
|
|
inquirer.prompt([{
|
|
type: 'input',
|
|
name: 'msg',
|
|
message: '请输入需要提交的消息', // 问题
|
|
default: '', // 默认值
|
|
validate: (input) => {
|
|
if (input.length == 0) { //
|
|
return '消息不能为空'
|
|
}
|
|
return true;
|
|
}
|
|
}]).then(async answers => {
|
|
if (answers.msg) {
|
|
resolve(answers.msg);
|
|
} else {
|
|
resolve('');
|
|
}
|
|
})
|
|
})
|
|
},
|
|
listPush(origin) {
|
|
return new Promise((resolve, reject) => {
|
|
inquirer.prompt([{
|
|
type: 'checkbox', // 问题类型,包括input,number,confirm,list,rawlist,password
|
|
choices: origin,
|
|
name: 'choices',
|
|
message: '请选择一个源提交', // 问题
|
|
default: true // 默认值
|
|
}]).then(async answers => {
|
|
resolve(answers.choices);
|
|
})
|
|
})
|
|
},
|
|
addRemote() {
|
|
return new Promise((resolve, reject) => {
|
|
inquirer.prompt([{
|
|
type: 'input', // 问题类型,包括input,number,confirm,list,rawlist,password
|
|
name: 'name',
|
|
message: '源名字', // 问题
|
|
default: '', // 默认值
|
|
validate: (input) => {
|
|
if (input.length == 0) {
|
|
return '请输入源名字';
|
|
}
|
|
return true;
|
|
}
|
|
}, {
|
|
type: 'input', // 问题类型,包括input,number,confirm,list,rawlist,password
|
|
name: 'url',
|
|
message: '源url', // 问题
|
|
default: '', // 默认值
|
|
validate: (input) => {
|
|
if (input.length == 0) {
|
|
return '请输入源url';
|
|
}
|
|
return true;
|
|
}
|
|
}]).then(async answers => {
|
|
resolve({
|
|
name: answers.name,
|
|
url: answers.url
|
|
});
|
|
})
|
|
})
|
|
}
|
|
}
|