plugin
Generated reference page for the plugin function export.
- Import:
@kjanat/dreamcli - Export kind: function
- Declared in:
src/core/cli/plugin.ts - Source link:
packages/dreamcli/src/core/cli/plugin.ts:105
Signatures
ts
function plugin(hooks: CLIPluginHooks, name?: string): CLIPlugin;| Parameter | Type | Description |
|---|---|---|
hooks | CLIPluginHooks | Lifecycle hooks to register. |
name | string | undefined | Optional plugin name for diagnostics. |
Members
Members
plugin
Create a CLI plugin from lifecycle hooks.
ts
(hooks: CLIPluginHooks, name?: string): CLIPlugin;Examples
ts
import { cli, command, plugin } from '@kjanat/dreamcli';
const deploy = command('deploy').action(({ out }) => {
out.log('deploying');
});
const trace = plugin(
{
beforeParse: ({ argv, out }) => {
out.info(`argv: ${argv.join(' ')}`);
},
afterResolve: ({ flags, args }) => {
console.log({ flags, args });
},
},
'trace',
);
cli('mycli').plugin(trace).command(deploy).run();