1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
tdzl2003 2016-04-03 16:50:28 +08:00
parent c2c3760fb5
commit f1694be238
2 changed files with 35 additions and 12 deletions

View File

@ -23,6 +23,11 @@
} }
}, },
"apps": { "apps": {
"options": {
"platform": {
"hasValue": true
}
}
}, },
"deleteApp": { "deleteApp": {
}, },

View File

@ -36,6 +36,32 @@ export async function getSelectedApp(platform) {
return updateInfo[platform]; return updateInfo[platform];
} }
export async function listApp(platform){
const {data} = await get('/app/list');
const list = platform?data.filter(v=>v.platform===platform):data;
for (const app of list) {
console.log(`${app.id}) ${app.name}(${app.platform})`);
}
if (platform) {
console.log(`\nTotal ${list.length} ${platform} apps`);
} else {
console.log(`\nTotal ${list.length} apps`);
}
return list;
}
export async function chooseApp(platform) {
const list = await listApp(platform);
while (true) {
const id = await question('Platform(ios/android):');
const app = list.find(v=>v.id === id);
if (app) {
return app;
}
}
}
export const commands = { export const commands = {
createApp: async function ({options}) { createApp: async function ({options}) {
const name = options.name || await question('App Name:'); const name = options.name || await question('App Name:');
@ -55,22 +81,14 @@ export const commands = {
await doDelete(`/app/${id}`); await doDelete(`/app/${id}`);
console.log('Ok.'); console.log('Ok.');
}, },
apps: async function (_, platform){ apps: async function ({options}){
const {data} = await get('/app/list'); const {platform} = options;
const list = platform?data.filter(v=>v.platform===platform):data; listApp(platform);
for (const app of list) {
console.log(`${app.id}) ${app.name}(${app.platform})`);
}
if (platform) {
console.log(`\nTotal ${list.length} ${platform} apps`);
} else {
console.log(`\nTotal ${list.length} apps`);
}
}, },
selectApp: async function({args, options}) { selectApp: async function({args, options}) {
const {platform} = options; const {platform} = options;
checkPlatform(platform); checkPlatform(platform);
const id = args[0] || ((await this.apps(null, platform)), (await question('Choose App used for ${platform}:'))); const id = args[0] || (await chooseApp()).id;
let updateInfo = {}; let updateInfo = {};
if (await fs.exists('update.json')) { if (await fs.exists('update.json')) {