@@ -4,32 +4,26 @@ import { State } from "./state";
44/**
55 * The context of a command execution
66 */
7- export type CommandContext = {
7+ export interface CommandContext {
88 opts : CommandOptions ;
99 stdin : string ;
1010 state : State ;
1111 runtime : BaseRuntime ;
1212} ;
1313
14- /**
15- * The handler of a command execution
16- */
17- export type CommandHandler = ( ctx : CommandContext ) => Promise < CommandResult > ;
18-
1914/**
2015 * The result of a command execution
2116 */
22- export type CommandResult = {
17+ export interface CommandResult {
2318 stdout : string ;
2419 stderr : string ;
2520 exitCode : number ;
2621} ;
2722
28-
2923/**
3024 * The options of a command execution
3125 */
32- export type CommandOptions = {
26+ export interface CommandOptions {
3327 raw : string [ ] ;
3428 flags : Set < string > ;
3529 options : Map < string , string > ;
@@ -40,10 +34,32 @@ export type CommandOptions = {
4034/**
4135 * The manual of a command
4236 */
43- export type CommandManual = {
37+ export interface CommandManual {
4438 name : string ;
4539 description : string ;
4640 usage : string ;
4741 options ?: Record < string , string > ;
4842} ;
4943
44+ /**
45+ * The custom command creation result
46+ */
47+ export interface CustomCommand {
48+ name : string ;
49+ handler : CommandHandler ;
50+ manual ?: CommandManual ;
51+ }
52+
53+ /**
54+ * The handler of a command execution
55+ */
56+ export type CommandHandler = ( ctx : CommandContext ) => Promise < CommandResult > ;
57+
58+
59+ /**
60+ * The builder to create a custom command
61+ */
62+ export type CreateCustomCommand = ( name : string , handler : CommandHandler , manual ?: CommandManual ) => CustomCommand ;
63+
64+
65+
0 commit comments