Skip to content

Help flag causes an error with Standalone usage #1388

@jonny133

Description

@jonny133

Describe the bug
When using @oclif/core@4.3.1, as described in Standalone usage section in the README, the help flag causes an error

To Reproduce

When using standalone class extends Command

❯ node standalone.js --help
 ›   Error: Parsing --help 
 ›      Command ls not found.
 ›   See more help with --help

When using Parser.parse(), having added the help flag help: Flags.help()

node_modules/@oclif/core/lib/help/index.js:332
    if (config.pjson.oclif?.helpClass) {
               ^

TypeError: Parsing --help 
        Cannot read properties of undefined (reading 'pjson')
See more help with --help
    at loadHelpClass (/oclif-repro/node_modules/@oclif/core/lib/help/index.js:332:16)
    at Object.parse (/oclif-repro/node_modules/@oclif/core/lib/flags.js:114:53)
    at parseFlagOrThrowError (/oclif-repro/node_modules/@oclif/core/lib/parser/parse.js:279:39)
    at Object.valueFunction (/oclif-repro/node_modules/@oclif/core/lib/parser/parse.js:301:53)
    at /oclif-repro/node_modules/@oclif/core/lib/parser/parse.js:420:113
    at Array.map (<anonymous>)
    at Parser._flags (/oclif-repro/node_modules/@oclif/core/lib/parser/parse.js:420:14)
    at Parser.parse (/oclif-repro/node_modules/@oclif/core/lib/parser/parse.js:183:93)
    at async Object.parse (/oclif-repro/node_modules/@oclif/core/lib/parser/index.js:21:20)
    at async file:///oclif-repro/index.js:4:25

Node.js v20.11.1

Expected behavior
Help is brought up showing appropriate flags/args etc.

Environment (please complete the following information):

  • OS & version: MacOS Sequoia
  • Shell/terminal & version [e.g. bash-3.2, bash-5.0, zsh 5.8, powershell 7.2.4, cmd.exe, Windows Terminal w/ powershell, etc... ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions