1- import { defineCommand } from './command' ;
1+ import type { Command } from './command' ;
22import { CLIError } from './errors/base' ;
33import { ExitCode } from './errors/codes' ;
44
@@ -25,44 +25,7 @@ import fileList from './commands/file/list';
2525import fileDelete from './commands/file/delete' ;
2626import update from './commands/update' ;
2727
28- import type { Config } from './config/schema' ;
29- import type { GlobalFlags } from './types/flags' ;
30-
31- export interface OptionDef {
32- flag : string ;
33- description : string ;
34- type ?: 'string' | 'number' | 'boolean' | 'array' ;
35- required ?: boolean ;
36- }
37-
38- export interface Command {
39- name : string ;
40- description : string ;
41- usage ?: string ;
42- options ?: OptionDef [ ] ;
43- examples ?: string [ ] ;
44- execute ( config : Config , flags : GlobalFlags ) : Promise < void > ;
45- }
46-
47- export interface CommandSpec {
48- name : string ;
49- description : string ;
50- usage ?: string ;
51- options ?: OptionDef [ ] ;
52- examples ?: string [ ] ;
53- run ( config : Config , flags : GlobalFlags ) : Promise < void > ;
54- }
55-
56- export function defineCommand ( spec : CommandSpec ) : Command {
57- return {
58- name : spec . name ,
59- description : spec . description ,
60- usage : spec . usage ,
61- options : spec . options ,
62- examples : spec . examples ,
63- execute : spec . run ,
64- } ;
65- }
28+ export type { Command , OptionDef } from './command' ;
6629
6730interface CommandNode {
6831 command ?: Command ;
@@ -145,7 +108,7 @@ class CommandRegistry {
145108 * Defaults to stdout; pass stderr (or a non-TTY stream) to keep stdout
146109 * clean for piped / JSON output.
147110 */
148- printHelp ( commandPath : string [ ] , out : typeof process . stdout = process . stdout ) : void {
111+ printHelp ( commandPath : string [ ] , out : NodeJS . WriteStream = process . stdout ) : void {
149112 if ( commandPath . length === 0 ) {
150113 this . printRootHelp ( out ) ;
151114 return ;
@@ -173,7 +136,7 @@ class CommandRegistry {
173136 out . write ( '\n' ) ;
174137 }
175138
176- private printRootHelp ( out : typeof process . stdout ) : void {
139+ private printRootHelp ( out : NodeJS . WriteStream ) : void {
177140 out . write ( `
178141 __ __ ___ _ _ ___ __ __ _ __ __
179142 | \\/ |_ _| \\ | |_ _| \\/ | / \\ \\ \\/ /
@@ -219,7 +182,7 @@ Getting Help:
219182` ) ;
220183 }
221184
222- private printCommandHelp ( cmd : Command , out : typeof process . stdout ) : void {
185+ private printCommandHelp ( cmd : Command , out : NodeJS . WriteStream ) : void {
223186 out . write ( `\n${ cmd . description } \n` ) ;
224187 if ( cmd . usage ) out . write ( `Usage: ${ cmd . usage } \n` ) ;
225188 if ( cmd . options && cmd . options . length > 0 ) {
@@ -241,7 +204,7 @@ Getting Help:
241204 out . write ( `Run 'minimax --help' for the full list.\n` ) ;
242205 }
243206
244- private printChildren ( node : CommandNode , prefix : string , out : typeof process . stdout ) : void {
207+ private printChildren ( node : CommandNode , prefix : string , out : NodeJS . WriteStream ) : void {
245208 for ( const [ name , child ] of node . children ) {
246209 if ( child . command ) {
247210 out . write ( ` ${ prefix } ${ name . padEnd ( 12 ) } ${ child . command . description } \n` ) ;
0 commit comments