lukeed / lukeed/sade

Cannot lazy parse and support `help`/`version` at same time

Open
#56 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.1k
Forks
24
PR merge metrics
No merged PRs in 30d

Description

https://github.com/lukeed/sade/blob/1cdf3e464ca899dcd6e758a50eb82cf7cf484771/src/index.js#L150-L152

The early return here will break the following:

```js
const prog = sade('cool-cli', true).version('1.0.0').describe('Some cool CLI.')

const {args} = prog.parse(process.argv, {lazy: true})

if (args.something) {
// do stuff
}
```

This is inconsistent with the documentation:

https://github.com/lukeed/sade/blob/1cdf3e464ca899dcd6e758a50eb82cf7cf484771/readme.md?plain=1#L638-L653

One solution may be to return:

```js
{
args: [],
name: '',
handler: undefined,
helpOrVersion: true // indicates the user passed one of the options
}
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/index.js lines 150-152 and compare the lazy parsing behavior with the documented contract in readme.md lines 638-653. Reproduce the example using version, describe, and parse(..., {lazy: true}); done means help/version options no longer trigger the early-return inconsistency and the lazy parse result exposes the needed state.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.