Skip to content

Commit

Permalink
feat: init plugin cli
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Apr 30, 2023
1 parent 8ac7dbf commit fcb764a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions packages/cli/src/system/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
8 changes: 5 additions & 3 deletions packages/core/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>;

command?: (space: AnimeSpace, cli: Breadc<{}>) => Promise<void>;
command?: (space: AnimeSystem, cli: Breadc<{}>) => Promise<void>;

introspect?: (space: AnimeSpace, anime: string) => Promise<void>;
introspect?: (space: AnimeSystem, anime: string) => Promise<void>;

refresh?: (space: AnimeSpace, anime: string) => Promise<void>;
refresh?: (space: AnimeSystem, anime: string) => Promise<void>;
}

0 comments on commit fcb764a

Please sign in to comment.