This commit is contained in:
2025-04-26 03:15:11 +08:00
parent 9eb4d06939
commit bcc12209e0
28 changed files with 1708 additions and 126 deletions

View File

@@ -0,0 +1,68 @@
import { AssistantApp } from '@/module/assistant/index.ts';
import { program, Command, assistantConfig } from '@/program.ts';
const appManagerCommand = new Command('app-manager').alias('am').description('Manage Assistant Apps 管理本地的应用模块');
program.addCommand(appManagerCommand);
appManagerCommand
.command('list')
.description('List all installed apps')
.action(async () => {
const manager = new AssistantApp(assistantConfig);
await manager.loadConfig();
const showInfos = manager.getAllAppShowInfo();
console.log('Installed Apps:', showInfos);
});
appManagerCommand
.command('detect')
.description('Detect all installed apps')
.action(async () => {
const manager = new AssistantApp(assistantConfig);
await manager.loadConfig();
const showInfos = await manager.detectApp();
if (showInfos === true) {
const showInfos = manager.getAllAppShowInfo();
console.log('Installed Apps:', showInfos);
} else {
console.log('Install New Apps:', showInfos);
}
});
appManagerCommand
.command('start')
.argument('<app-key-name>', '应用的 key 名称')
.action(async (appKey: string) => {
const manager = new AssistantApp(assistantConfig);
await manager.loadConfig();
manager.start(appKey);
console.log('Start App:', appKey);
});
appManagerCommand
.command('stop')
.argument('<app-key-name>', '应用的 key 名称')
.action(async (appKey: string) => {
const manager = new AssistantApp(assistantConfig);
try {
await manager.loadConfig();
await manager.stop(appKey);
} catch (error) {
console.error(error);
}
console.log('Stop App:', appKey);
});
appManagerCommand
.command('restart')
.argument('<app-key-name>', '应用的 key 名称')
.action(async (appKey: string) => {
const manager = new AssistantApp(assistantConfig);
try {
await manager.loadConfig();
await manager.restart(appKey);
} catch (error) {
console.error(error);
}
console.log('Restart App:', appKey);
});