@@ -110,6 +110,84 @@ const renderPreviewHelp = (): string =>
110110 ] ,
111111 } ) ;
112112
113+ const renderLibHelp = ( ) : string =>
114+ renderHelp ( {
115+ usage : 'rs lib [command] [options]' ,
116+ sections : [
117+ {
118+ title : 'Commands' ,
119+ items : [
120+ [ 'build' , 'Build the library for production (default)' ] ,
121+ [ 'inspect' , 'Inspect Rslib, Rsbuild, and Rspack configs' ] ,
122+ [ 'mf-dev' , 'Start Rsbuild dev server for Module Federation' ] ,
123+ ] ,
124+ } ,
125+ {
126+ content : `For command-specific options, run:
127+ $ rs lib <command> -h` ,
128+ dim : true ,
129+ } ,
130+ {
131+ title : 'Options' ,
132+ items : [
133+ [ '-w, --watch' , 'Enable watch mode and rebuild on changes' ] ,
134+ [ '--dts' , 'Emit declaration files (use --no-dts to disable)' ] ,
135+ [ '-c, --config <path>' , 'Specify Rstack config file path' ] ,
136+ [ '-h, --help' , 'Display this help message' ] ,
137+ ] ,
138+ } ,
139+ ] ,
140+ } ) ;
141+
142+ const renderLibBuildHelp = ( ) : string =>
143+ renderHelp ( {
144+ usage : 'rs lib build [options]' ,
145+ description : 'Build the library for production' ,
146+ sections : [
147+ {
148+ title : 'Options' ,
149+ items : [
150+ [ '-w, --watch' , 'Enable watch mode and rebuild on changes' ] ,
151+ [ '--dts' , 'Emit declaration files (use --no-dts to disable)' ] ,
152+ [ '-c, --config <path>' , 'Specify Rstack config file path' ] ,
153+ [ '-h, --help' , 'Display this help message' ] ,
154+ ] ,
155+ } ,
156+ ] ,
157+ } ) ;
158+
159+ const renderLibInspectHelp = ( ) : string =>
160+ renderHelp ( {
161+ usage : 'rs lib inspect [options]' ,
162+ description : 'Inspect Rslib, Rsbuild, and Rspack configs' ,
163+ sections : [
164+ {
165+ title : 'Options' ,
166+ items : [
167+ [ '--output <path>' , 'Set the output path for inspection results (default: .rsbuild)' ] ,
168+ [ '--verbose' , 'Show complete function definitions in output' ] ,
169+ [ '-c, --config <path>' , 'Specify Rstack config file path' ] ,
170+ [ '-h, --help' , 'Display this help message' ] ,
171+ ] ,
172+ } ,
173+ ] ,
174+ } ) ;
175+
176+ const renderLibMfDevHelp = ( ) : string =>
177+ renderHelp ( {
178+ usage : 'rs lib mf-dev [options]' ,
179+ description : 'Start Rsbuild dev server for Module Federation' ,
180+ sections : [
181+ {
182+ title : 'Options' ,
183+ items : [
184+ [ '-c, --config <path>' , 'Specify Rstack config file path' ] ,
185+ [ '-h, --help' , 'Display this help message' ] ,
186+ ] ,
187+ } ,
188+ ] ,
189+ } ) ;
190+
113191async function runRsbuildCLI ( args : string [ ] ) : Promise < void > {
114192 if ( hasHelpFlag ( args ) ) {
115193 switch ( args [ 0 ] ) {
@@ -147,6 +225,23 @@ async function runRstestCLI(args: string[]): Promise<void> {
147225}
148226
149227async function runRslibCLI ( args : string [ ] ) : Promise < void > {
228+ if ( hasHelpFlag ( args ) ) {
229+ switch ( args [ 0 ] ) {
230+ case 'build' :
231+ console . log ( renderLibBuildHelp ( ) ) ;
232+ return ;
233+ case 'inspect' :
234+ console . log ( renderLibInspectHelp ( ) ) ;
235+ return ;
236+ case 'mf-dev' :
237+ console . log ( renderLibMfDevHelp ( ) ) ;
238+ return ;
239+ default :
240+ console . log ( renderLibHelp ( ) ) ;
241+ return ;
242+ }
243+ }
244+
150245 const argv = [
151246 process . execPath ,
152247 'rslib' ,
0 commit comments