@@ -46,7 +46,7 @@ To get help for a specific task run: npx hardhat task <SUBTASK> --help`;
46
46
47
47
describe ( "when the task is not empty" , function ( ) {
48
48
describe ( "when there are options" , function ( ) {
49
- it ( "should return the task's help string" , async function ( ) {
49
+ it ( "should return the task's help string with options sorted by name " , async function ( ) {
50
50
const task : Task = {
51
51
id : [ "task" ] ,
52
52
description : "task description" ,
@@ -73,12 +73,12 @@ To get help for a specific task run: npx hardhat task <SUBTASK> --help`;
73
73
74
74
const expected = `${ chalk . bold ( "task description" ) }
75
75
76
- Usage: hardhat [GLOBAL OPTIONS] task [--option <STRING> ] [--another- option]
76
+ Usage: hardhat [GLOBAL OPTIONS] task [--another- option] [--option <STRING> ]
77
77
78
78
OPTIONS:
79
79
80
- --option An example option
81
80
--another-option Another example option
81
+ --option An example option
82
82
83
83
For global options help run: hardhat --help` ;
84
84
@@ -87,7 +87,7 @@ For global options help run: hardhat --help`;
87
87
} ) ;
88
88
89
89
describe ( "when there are positional arguments" , function ( ) {
90
- it ( "should return the task's help string" , async function ( ) {
90
+ it ( "should return the task's help string with options and positional arguments sorted by name, except in the usage string " , async function ( ) {
91
91
const task : Task = {
92
92
id : [ "task" ] ,
93
93
description : "task description" ,
@@ -110,6 +110,12 @@ For global options help run: hardhat --help`;
110
110
type : ArgumentType . STRING ,
111
111
isVariadic : false ,
112
112
} ,
113
+ {
114
+ name : "anotherPositionalArgument" ,
115
+ description : "Another example positional argument" ,
116
+ type : ArgumentType . STRING ,
117
+ isVariadic : false ,
118
+ } ,
113
119
] ,
114
120
pluginId : "task-plugin-id" ,
115
121
subtasks : new Map ( ) ,
@@ -121,16 +127,17 @@ For global options help run: hardhat --help`;
121
127
122
128
const expected = `${ chalk . bold ( "task description" ) }
123
129
124
- Usage: hardhat [GLOBAL OPTIONS] task [--option <STRING> ] [--another- option] [--] positionalArgument
130
+ Usage: hardhat [GLOBAL OPTIONS] task [--another- option] [--option <STRING> ] [--] positionalArgument anotherPositionalArgument
125
131
126
132
OPTIONS:
127
133
128
- --option An example option
129
- --another- option Another example option
134
+ --another- option Another example option
135
+ --option An example option
130
136
131
137
POSITIONAL ARGUMENTS:
132
138
133
- positionalArgument An example positional argument
139
+ anotherPositionalArgument Another example positional argument
140
+ positionalArgument An example positional argument
134
141
135
142
For global options help run: hardhat --help` ;
136
143
@@ -139,7 +146,7 @@ For global options help run: hardhat --help`;
139
146
} ) ;
140
147
141
148
describe ( "when there are subtasks" , function ( ) {
142
- it ( "should return the task's help string" , async function ( ) {
149
+ it ( "should return the task's help string with subtasks sorted by name " , async function ( ) {
143
150
const task : Task = {
144
151
id : [ "task" ] ,
145
152
description : "task description" ,
@@ -164,10 +171,15 @@ For global options help run: hardhat --help`;
164
171
} ,
165
172
] ,
166
173
pluginId : "task-plugin-id" ,
167
- subtasks : new Map ( ) . set ( "subtask" , {
168
- id : [ "task" , "subtask" ] ,
169
- description : "An example subtask" ,
170
- } ) ,
174
+ subtasks : new Map ( )
175
+ . set ( "subtask" , {
176
+ id : [ "task" , "subtask" ] ,
177
+ description : "An example subtask" ,
178
+ } )
179
+ . set ( "another-subtask" , {
180
+ id : [ "task" , "another-subtask" ] ,
181
+ description : "Another example subtask" ,
182
+ } ) ,
171
183
isEmpty : false ,
172
184
run : async ( ) => { } ,
173
185
} ;
@@ -176,20 +188,21 @@ For global options help run: hardhat --help`;
176
188
177
189
const expected = `${ chalk . bold ( "task description" ) }
178
190
179
- Usage: hardhat [GLOBAL OPTIONS] task [--option <STRING> ] [--another- option] [--] positionalArgument
191
+ Usage: hardhat [GLOBAL OPTIONS] task [--another- option] [--option <STRING> ] [--] positionalArgument
180
192
181
193
OPTIONS:
182
194
183
- --option An example option
184
- --another- option Another example option
195
+ --another- option Another example option
196
+ --option An example option
185
197
186
198
POSITIONAL ARGUMENTS:
187
199
188
- positionalArgument An example positional argument
200
+ positionalArgument An example positional argument
189
201
190
202
AVAILABLE SUBTASKS:
191
203
192
- task subtask An example subtask
204
+ task another-subtask Another example subtask
205
+ task subtask An example subtask
193
206
194
207
For global options help run: hardhat --help` ;
195
208
0 commit comments