* Set / get the command usage `str`. * * @param {string} [str] * @return {(string|Command)}
(str)
| 2316 | */ |
| 2317 | |
| 2318 | usage(str) { |
| 2319 | if (str === undefined) { |
| 2320 | if (this._usage) return this._usage; |
| 2321 | |
| 2322 | const args = this.registeredArguments.map((arg) => { |
| 2323 | return humanReadableArgName(arg); |
| 2324 | }); |
| 2325 | return [] |
| 2326 | .concat( |
| 2327 | this.options.length || this._helpOption !== null ? '[options]' : [], |
| 2328 | this.commands.length ? '[command]' : [], |
| 2329 | this.registeredArguments.length ? args : [], |
| 2330 | ) |
| 2331 | .join(' '); |
| 2332 | } |
| 2333 | |
| 2334 | this._usage = str; |
| 2335 | return this; |
| 2336 | } |
| 2337 | |
| 2338 | /** |
| 2339 | * Get or set the name of the command. |
no test coverage detected