Commit d8fd59a 1 parent 91e4c91 commit d8fd59a Copy full SHA for d8fd59a
File tree 5 files changed +49
-23
lines changed
5 files changed +49
-23
lines changed Original file line number Diff line number Diff line change 6
6
emptyTask ,
7
7
overrideTask ,
8
8
configVariable ,
9
+ globalOption ,
9
10
} from "@ignored/hardhat-vnext/config" ;
10
11
11
12
const exampleEmptyTask = emptyTask ( "empty" , "An example empty task" ) . build ( ) ;
@@ -116,6 +117,13 @@ const pluginExample = {
116
117
} )
117
118
. build ( ) ,
118
119
] ,
120
+ globalOptions : [
121
+ globalOption ( {
122
+ name : "myGlobalOption" ,
123
+ description : "A global option" ,
124
+ defaultValue : "default" ,
125
+ } ) ,
126
+ ] ,
119
127
} ;
120
128
121
129
const config : HardhatUserConfig = {
Original file line number Diff line number Diff line change 1
- export const BUILTIN_OPTIONS : Array < {
2
- name : string ;
3
- description : string ;
4
- } > = [
5
- {
6
- name : "--config" ,
1
+ import type { GlobalOption } from "../types/global-options.js" ;
2
+
3
+ import { globalOption , ParameterType } from "../config.js" ;
4
+
5
+ export const BUILTIN_OPTIONS : GlobalOption [ ] = [
6
+ globalOption ( {
7
+ name : "config" ,
7
8
description : "A Hardhat config file." ,
8
- } ,
9
- {
10
- name : "--help" ,
11
- description : "Shows this message, or a task's help if its name is provided" ,
12
- } ,
13
- {
14
- name : "--show-stack-traces" ,
9
+ parameterType : ParameterType . STRING ,
10
+ defaultValue : "" ,
11
+ } ) ,
12
+ globalOption ( {
13
+ name : "help" ,
14
+ description :
15
+ "Shows this message, or a task's help if its name is provided." ,
16
+ parameterType : ParameterType . BOOLEAN ,
17
+ defaultValue : false ,
18
+ } ) ,
19
+ globalOption ( {
20
+ name : "showStackTraces" ,
15
21
description : "Show stack traces (always enabled on CI servers)." ,
16
- } ,
17
- {
18
- name : "--version" ,
22
+ parameterType : ParameterType . BOOLEAN ,
23
+ defaultValue : false ,
24
+ } ) ,
25
+ globalOption ( {
26
+ name : "version" ,
19
27
description : "Shows hardhat's version." ,
20
- } ,
28
+ parameterType : ParameterType . BOOLEAN ,
29
+ defaultValue : false ,
30
+ } ) ,
21
31
] ;
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { getHardhatVersion } from "../../utils/package.js";
5
5
6
6
import {
7
7
GLOBAL_NAME_PADDING ,
8
+ formatOptionName ,
8
9
getLongestNameLength ,
9
10
getSection ,
10
11
parseTasks ,
@@ -17,8 +18,15 @@ export async function getGlobalHelpString(
17
18
18
19
const { tasks, subtasks } = parseTasks ( rootTasks ) ;
19
20
21
+ const formattedBuiltinOptions = BUILTIN_OPTIONS . map (
22
+ ( { name, description } ) => ( {
23
+ name : formatOptionName ( name ) ,
24
+ description,
25
+ } ) ,
26
+ ) ;
27
+
20
28
const namePadding =
21
- getLongestNameLength ( [ ...tasks , ...subtasks , ...BUILTIN_OPTIONS ] ) +
29
+ getLongestNameLength ( [ ...tasks , ...subtasks , ...formattedBuiltinOptions ] ) +
22
30
GLOBAL_NAME_PADDING ;
23
31
24
32
let output = `Hardhat version ${ version }
@@ -34,7 +42,7 @@ Usage: hardhat [GLOBAL OPTIONS] <TASK> [SUBTASK] [TASK OPTIONS] [--] [TASK ARGUM
34
42
output += getSection ( "AVAILABLE SUBTASKS" , subtasks , namePadding ) ;
35
43
}
36
44
37
- output += getSection ( "GLOBAL OPTIONS" , BUILTIN_OPTIONS , namePadding ) ;
45
+ output += getSection ( "GLOBAL OPTIONS" , formattedBuiltinOptions , namePadding ) ;
38
46
39
47
output += `\nTo get help for a specific task run: npx hardhat <TASK> [SUBTASK] --help` ;
40
48
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ Usage: hardhat [GLOBAL OPTIONS] <TASK> [SUBTASK] [TASK OPTIONS] [--] [TASK ARGUM
22
22
GLOBAL OPTIONS:
23
23
24
24
--config A Hardhat config file.
25
- --help Shows this message, or a task's help if its name is provided
25
+ --help Shows this message, or a task's help if its name is provided.
26
26
--show-stack-traces Show stack traces (always enabled on CI servers).
27
27
--version Shows hardhat's version.
28
28
@@ -79,7 +79,7 @@ AVAILABLE TASKS:
79
79
GLOBAL OPTIONS:
80
80
81
81
--config A Hardhat config file.
82
- --help Shows this message, or a task's help if its name is provided
82
+ --help Shows this message, or a task's help if its name is provided.
83
83
--show-stack-traces Show stack traces (always enabled on CI servers).
84
84
--version Shows hardhat's version.
85
85
@@ -150,7 +150,7 @@ AVAILABLE SUBTASKS:
150
150
GLOBAL OPTIONS:
151
151
152
152
--config A Hardhat config file.
153
- --help Shows this message, or a task's help if its name is provided
153
+ --help Shows this message, or a task's help if its name is provided.
154
154
--show-stack-traces Show stack traces (always enabled on CI servers).
155
155
--version Shows hardhat's version.
156
156
Original file line number Diff line number Diff line change @@ -222,7 +222,7 @@ AVAILABLE TASKS:
222
222
GLOBAL OPTIONS:
223
223
224
224
--config A Hardhat config file.
225
- --help Shows this message, or a task's help if its name is provided
225
+ --help Shows this message, or a task's help if its name is provided.
226
226
--show-stack-traces Show stack traces (always enabled on CI servers).
227
227
--version Shows hardhat's version.
228
228
You can’t perform that action at this time.
0 commit comments