@@ -167,7 +167,7 @@ function _global_options(argv) {
167167 flags . push ( def_flag ( argv [ 'log-file' ] , ( argv [ 'log-file' ] ) ? '--log-file' : '--no-log-file' ) ) ;
168168 flags . push ( def_flag ( argv [ 'elapsed-time' ] , ( argv [ 'elapsed-time' ] ) ? '--elapsed-time' : '--no-elapsed-time' ) ) ;
169169 flags . push ( def_flag ( argv [ 'no-color' ] , '--no-color' ) ) ;
170- /* Number type */
170+ /* Numeric type */
171171 flags . push ( def_flag ( argv . verbose , '--verbose' , argv . verbose ) ) ;
172172 /* String type */
173173 flags . push ( def_flag ( argv . proxy , '--proxy' , argv . proxy ) ) ;
@@ -177,6 +177,23 @@ function _global_options(argv) {
177177 return flags ;
178178}
179179
180+ /**
181+ * Check any invalid arguments or options.
182+ * @param { JSON } (argv - Argument vector.
183+ * @return Return true if there is no input error.
184+ */
185+ function _check_argv ( argv ) {
186+ /* Numeric type */
187+ if ( argv . verbose !== undefined &&
188+ // this must exclude NaN -- yargs default value for numeric type
189+ ! ( argv . verbose >= 0 && argv . verbose <= 5 ) ) {
190+ console . warn ( "invalid value for --verbose option: must be a number between 0 and 5" ) ;
191+ return false ;
192+ }
193+
194+ return true ;
195+ }
196+
180197/**
181198 * Form elisp script path.
182199 * @param { string } name - Name of the script without extension.
@@ -212,6 +229,11 @@ async function e_call(argv, script, ...args) {
212229 return ;
213230 }
214231
232+ if ( ! _check_argv ( argv ) ) {
233+ process . exit ( 1 ) ;
234+ return ;
235+ }
236+
215237 return new Promise ( resolve => {
216238 let _path = el_script ( script ) ;
217239
0 commit comments