@@ -37,6 +37,7 @@ const webpackSchema = require("../schemas/WebpackOptions.json");
3737/**
3838 * @typedef {Object } ArgumentConfig
3939 * @property {string } description
40+ * @property {string } [negatedDescription]
4041 * @property {string } path
4142 * @property {boolean } multiple
4243 * @property {"enum"|"string"|"path"|"number"|"boolean"|"RegExp"|"reset" } type
@@ -96,11 +97,42 @@ const getArguments = (schema = webpackSchema) => {
9697 */
9798 const getDescription = path => {
9899 for ( const { schema } of path ) {
99- if ( schema . cli && schema . cli . helper ) continue ;
100+ if ( schema . cli ) {
101+ if ( schema . cli . helper ) continue ;
102+ if ( schema . cli . description ) return schema . cli . description ;
103+ }
100104 if ( schema . description ) return schema . description ;
101105 }
102106 } ;
103107
108+ /**
109+ *
110+ * @param {PathItem[] } path path in the schema
111+ * @returns {string | undefined } negative description
112+ */
113+ const getNegatedDescription = path => {
114+ for ( const { schema } of path ) {
115+ if ( schema . cli ) {
116+ if ( schema . cli . helper ) continue ;
117+ if ( schema . cli . negatedDescription ) return schema . cli . negatedDescription ;
118+ }
119+ }
120+ } ;
121+
122+ /**
123+ *
124+ * @param {PathItem[] } path path in the schema
125+ * @returns {string | undefined } reset description
126+ */
127+ const getResetDescription = path => {
128+ for ( const { schema } of path ) {
129+ if ( schema . cli ) {
130+ if ( schema . cli . helper ) continue ;
131+ if ( schema . cli . resetDescription ) return schema . cli . resetDescription ;
132+ }
133+ }
134+ } ;
135+
104136 /**
105137 *
106138 * @param {any } schemaPart schema
@@ -142,13 +174,17 @@ const getArguments = (schema = webpackSchema) => {
142174 const addResetFlag = path => {
143175 const schemaPath = path [ 0 ] . path ;
144176 const name = pathToArgumentName ( `${ schemaPath } .reset` ) ;
145- const description = getDescription ( path ) ;
177+ const description =
178+ getResetDescription ( path ) ||
179+ `Clear all items provided in '${ schemaPath } ' configuration. ${ getDescription (
180+ path
181+ ) } `;
146182 flags [ name ] = {
147183 configs : [
148184 {
149185 type : "reset" ,
150186 multiple : false ,
151- description : `Clear all items provided in ' ${ schemaPath } ' configuration. ${ description } ` ,
187+ description,
152188 path : schemaPath
153189 }
154190 ] ,
@@ -167,6 +203,7 @@ const getArguments = (schema = webpackSchema) => {
167203 const argConfigBase = schemaToArgumentConfig ( path [ 0 ] . schema ) ;
168204 if ( ! argConfigBase ) return 0 ;
169205
206+ const negatedDescription = getNegatedDescription ( path ) ;
170207 const name = pathToArgumentName ( path [ 0 ] . path ) ;
171208 /** @type {ArgumentConfig } */
172209 const argConfig = {
@@ -176,6 +213,10 @@ const getArguments = (schema = webpackSchema) => {
176213 path : path [ 0 ] . path
177214 } ;
178215
216+ if ( negatedDescription ) {
217+ argConfig . negatedDescription = negatedDescription ;
218+ }
219+
179220 if ( ! flags [ name ] ) {
180221 flags [ name ] = {
181222 configs : [ ] ,
0 commit comments