feat: add silky cli tools
This commit is contained in:
36
assistant/src/command/app/index.ts
Normal file
36
assistant/src/command/app/index.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { program, Command, assistantConfig } from '@/program.ts';
|
||||
import { AppDownload } from '@/services/app/index.ts';
|
||||
|
||||
const appManagerCommand = new Command('app').description('本地的应用模块的安装和下载, 分为 app 和 web 两种类型');
|
||||
program.addCommand(appManagerCommand);
|
||||
|
||||
const downloadCommand = new Command('download')
|
||||
.description('下载应用')
|
||||
.option('-i, --id <id>', '应用名称')
|
||||
.option('-t, --type <type>', '应用类型', 'web')
|
||||
.option('-r, --registry <registry>', '应用源 https://kevisual.cn')
|
||||
.action(async (options) => {
|
||||
const { id, type } = options;
|
||||
assistantConfig.checkMounted();
|
||||
const registry = options.registry || assistantConfig.getRegistry();
|
||||
// console.log('registry', registry);
|
||||
const app = new AppDownload(assistantConfig);
|
||||
if (id) {
|
||||
await app.downloadApp({ id, type, registry });
|
||||
}
|
||||
});
|
||||
|
||||
appManagerCommand.addCommand(downloadCommand);
|
||||
|
||||
const deleteCommand = new Command('delete')
|
||||
.description('删除应用')
|
||||
.option('-i, --id <id>', '应用名称')
|
||||
.option('-t, --type <type>', '应用类型', 'web')
|
||||
.action(async (options) => {
|
||||
const { id, type } = options;
|
||||
const app = new AppDownload(assistantConfig);
|
||||
if (id) {
|
||||
await app.deleteApp({ id, type });
|
||||
}
|
||||
});
|
||||
appManagerCommand.addCommand(deleteCommand);
|
||||
Reference in New Issue
Block a user