init
This commit is contained in:
68
assistant/src/command/app-manager/index.ts
Normal file
68
assistant/src/command/app-manager/index.ts
Normal 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);
|
||||
});
|
||||
Reference in New Issue
Block a user