Skip to content

Commit 32be048

Browse files
committed
Preserve options' order when showing prompts
1 parent 24ce246 commit 32be048

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/interactive-command.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,18 @@ export class InteractiveCommand extends Command {
221221
)
222222
.filter(Boolean) as Option[];
223223

224+
nonCliOptions.sort((a, b) => {
225+
const aIndex = command.options.findIndex(
226+
(option) => option.attributeName() === a.attributeName(),
227+
);
228+
229+
const bIndex = command.options.findIndex(
230+
(option) => option.attributeName() === b.attributeName(),
231+
);
232+
233+
return aIndex - bIndex;
234+
});
235+
224236
await command.readMissingOptions(
225237
nonCliOptions,
226238
providedOptions?.get(command) ?? {},

0 commit comments

Comments
 (0)