From fcb764a5b64efd806d5bead0a892a8428ab9dc0a Mon Sep 17 00:00:00 2001 From: XLor Date: Sun, 30 Apr 2023 22:59:56 +0800 Subject: [PATCH] feat: init plugin cli --- packages/cli/src/system/cli.ts | 3 +++ packages/core/src/plugin.ts | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/system/cli.ts b/packages/cli/src/system/cli.ts index 4717ae7f7..6f9d0ec07 100644 --- a/packages/cli/src/system/cli.ts +++ b/packages/cli/src/system/cli.ts @@ -5,5 +5,8 @@ import { version, description } from '../../package.json'; export async function makeCliApp(system: AnimeSystem) { const app = breadc('anime', { version, description }); + for (const plugin of system.space.plugins) { + await plugin.command?.(system, app); + } return app; } diff --git a/packages/core/src/plugin.ts b/packages/core/src/plugin.ts index 93a0a59eb..ec23286f1 100644 --- a/packages/core/src/plugin.ts +++ b/packages/core/src/plugin.ts @@ -2,14 +2,16 @@ import type { Breadc } from 'breadc'; import type { AnimeSpace } from './space/types'; +import type { AnimeSystem } from './system'; + export interface Plugin { name: string; prepare?: (space: AnimeSpace) => Promise; - command?: (space: AnimeSpace, cli: Breadc<{}>) => Promise; + command?: (space: AnimeSystem, cli: Breadc<{}>) => Promise; - introspect?: (space: AnimeSpace, anime: string) => Promise; + introspect?: (space: AnimeSystem, anime: string) => Promise; - refresh?: (space: AnimeSpace, anime: string) => Promise; + refresh?: (space: AnimeSystem, anime: string) => Promise; }