@@ -2,6 +2,8 @@ import type { ArgumentType } from "@ignored/hardhat-vnext-core/config";
2
2
import type { GlobalOptionDefinitions } from "@ignored/hardhat-vnext-core/types/global-options" ;
3
3
import type { Task } from "@ignored/hardhat-vnext-core/types/tasks" ;
4
4
5
+ import { camelToKebabCase } from "@ignored/hardhat-vnext-utils/string" ;
6
+
5
7
export const GLOBAL_NAME_PADDING = 6 ;
6
8
7
9
interface ArgumentDescriptor {
@@ -15,7 +17,7 @@ export function parseGlobalOptions(
15
17
globalOptionDefinitions : GlobalOptionDefinitions ,
16
18
) : ArgumentDescriptor [ ] {
17
19
return [ ...globalOptionDefinitions ] . map ( ( [ , { option } ] ) => ( {
18
- name : formatOptionName ( option . name ) ,
20
+ name : toCommandLineOption ( option . name ) ,
19
21
description : option . description ,
20
22
} ) ) ;
21
23
}
@@ -62,7 +64,7 @@ export function parseOptions(task: Task): {
62
64
63
65
for ( const [ optionName , option ] of task . options ) {
64
66
options . push ( {
65
- name : formatOptionName ( optionName ) ,
67
+ name : toCommandLineOption ( optionName ) ,
66
68
description : option . description ,
67
69
type : option . type ,
68
70
} ) ;
@@ -79,15 +81,8 @@ export function parseOptions(task: Task): {
79
81
return { options, positionalArguments } ;
80
82
}
81
83
82
- export function formatOptionName ( str : string ) : string {
83
- return `--${ str
84
- . split ( "" )
85
- . map ( ( letter , idx ) => {
86
- return letter . toUpperCase ( ) === letter
87
- ? `${ idx !== 0 ? "-" : "" } ${ letter . toLowerCase ( ) } `
88
- : letter ;
89
- } )
90
- . join ( "" ) } `;
84
+ export function toCommandLineOption ( optionName : string ) : string {
85
+ return `--${ camelToKebabCase ( optionName ) } ` ;
91
86
}
92
87
93
88
export function getLongestNameLength ( tasks : Array < { name : string } > ) : number {
0 commit comments