Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Shortname doesn't work with a single dash #81

@damusix

Description

@damusix

Bossy.usage() gives an incorrect way of calling alias shortname when greater than 1 character.

Given:

./sample.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:

node sample
Options:                           

  -o, --options           options
  -org, --organization    orgs

{
  options: undefined,
  o: undefined,
  organization: undefined,
  org: undefined
}
node sample -org test
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.<anonymous> (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
Options:                           

  -o, --options           options
  -org, --organization    orgs

{ organization: 'test', options: undefined, o: undefined, org: 'test' }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug or defect

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions