Shortname doesn't work with a single dash
- Dominant language
- JavaScript
- Stars
- 45
- Forks
- 30
- PR merge metrics
- No merged PRs in 30d
Description
`Bossy.usage()` gives an incorrect way of calling alias shortname when greater than 1 character.
**Given:**
`./sample.js`
```js
const definition = {
options: {
description: 'options',
alias: 'o'
},
organization: {
description: 'orgs',
alias: 'org' // this should console log usage as --org not -org
}
};
const args = Bossy.parse(definition);
console.log(
Bossy.usage(definition)
);
console.log(args);
```
**The following happens:**
```sh
node sample
```
```sh
Options:
-o, --options options
-org, --organization orgs
{
options: undefined,
o: undefined,
organization: undefined,
org: undefined
}
```
```sh
node sample -org test
```
```sh
Options:
-o, --options options
-org, --organization orgs
Error: Invalid option: options missing value
at Object.internals.formatError (project/node_modules/@hapi/bossy/lib/index.js:344:12)
at Object.exports.parse (project/node_modules/@hapi/bossy/lib/index.js:73:43)
at Object. (project/bin/sample:20:20)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
data: null,
isBoom: true,
isServer: true,
output: {
statusCode: 500,
payload: {
statusCode: 500,
error: 'Internal Server Error',
message: 'An internal server error occurred'
},
headers: {}
}
}
```
**But this works:**
```
node sample --org test
```
```sh
Options:
-o, --options options
-org, --organization orgs
{ organization: 'test', options: undefined, o: undefined, org: 'test' }
```
Contributor guide
Assessment
This issue has not been assessed yet.