(
{ options, aliases = new SafeMap(), firstColumn, secondColumn },
)
| 117 | } |
| 118 | |
| 119 | function format( |
| 120 | { options, aliases = new SafeMap(), firstColumn, secondColumn }, |
| 121 | ) { |
| 122 | let text = ''; |
| 123 | let maxFirstColumnUsed = 0; |
| 124 | |
| 125 | const sortedOptions = ArrayPrototypeSort( |
| 126 | [...options.entries()], |
| 127 | ({ 0: name1, 1: option1 }, { 0: name2, 1: option2 }) => { |
| 128 | if (option1.defaultIsTrue) { |
| 129 | name1 = `--no-${StringPrototypeSlice(name1, 2)}`; |
| 130 | } |
| 131 | if (option2.defaultIsTrue) { |
| 132 | name2 = `--no-${StringPrototypeSlice(name2, 2)}`; |
| 133 | } |
| 134 | return StringPrototypeLocaleCompare(name1, name2); |
| 135 | }, |
| 136 | ); |
| 137 | |
| 138 | for (const { |
| 139 | 0: name, 1: { helpText, type, defaultIsTrue }, |
| 140 | } of sortedOptions) { |
| 141 | if (!helpText) continue; |
| 142 | const value = getOptionValue(name); |
| 143 | |
| 144 | let displayName = name; |
| 145 | |
| 146 | if (defaultIsTrue) { |
| 147 | displayName = `--no-${StringPrototypeSlice(displayName, 2)}`; |
| 148 | } |
| 149 | |
| 150 | const argDescription = getArgDescription(type); |
| 151 | if (argDescription) |
| 152 | displayName += `=${argDescription}`; |
| 153 | |
| 154 | for (const { 0: from, 1: to } of aliases) { |
| 155 | // For cases like e.g. `-e, --eval`. |
| 156 | if (to[0] === name && to.length === 1) { |
| 157 | displayName = `${from}, ${displayName}`; |
| 158 | } |
| 159 | |
| 160 | // For cases like `--inspect-brk[=[host:]port]`. |
| 161 | const targetInfo = options.get(to[0]); |
| 162 | const targetArgDescription = |
| 163 | targetInfo ? getArgDescription(targetInfo.type) : '...'; |
| 164 | if (from === `${name}=`) { |
| 165 | displayName += `[=${targetArgDescription}]`; |
| 166 | } else if (from === `${name} <arg>`) { |
| 167 | displayName += ` [${targetArgDescription}]`; |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | let displayHelpText = helpText; |
| 172 | if (value === !defaultIsTrue) { |
| 173 | // Mark boolean options we currently have enabled. |
| 174 | // In particular, it indicates whether --use-openssl-ca |
| 175 | // or --use-bundled-ca is the (current) default. |
| 176 | displayHelpText += ' (currently set)'; |
no test coverage detected
searching dependent graphs…